Update ooo320-m1
[ooovba.git] / svx / source / dialog / svxruler.cxx
bloba8aa808ffe424997d19de78acd36aa8fbed242e9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svxruler.cxx,v $
10 * $Revision: 1.39.76.1 $
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_svx.hxx"
34 // INCLUDE ---------------------------------------------------------------
36 #include <string.h>
37 #include <limits.h>
38 #include <tools/shl.hxx>
39 #include <vcl/image.hxx>
40 #include <svtools/eitem.hxx>
41 #include <svtools/rectitem.hxx>
42 #include <sfx2/dispatch.hxx>
44 #include <svtools/smplhint.hxx>
50 #include <svx/dialogs.hrc>
51 #include <svx/dialmgr.hxx>
52 #include <svx/ruler.hxx>
53 #include "rlrcitem.hxx"
54 #include "rulritem.hxx"
55 #include <svx/tstpitem.hxx>
56 #include <svx/lrspitem.hxx>
57 #include "protitem.hxx"
58 #ifndef _APP_HXX
59 #include <vcl/svapp.hxx>
60 #endif
61 #ifndef RULER_TAB_RTL
62 #define RULER_TAB_RTL ((USHORT)0x0010)
63 #endif
65 // STATIC DATA -----------------------------------------------------------
67 #define CTRL_ITEM_COUNT 14
68 #define GAP 10
69 #define OBJECT_BORDER_COUNT 4
70 #define TAB_GAP 1
71 #define INDENT_GAP 2
72 #define INDENT_FIRST_LINE 4
73 #define INDENT_LEFT_MARGIN 5
74 #define INDENT_RIGHT_MARGIN 6
75 #define INDENT_LEFT_BORDER 2
76 #define INDENT_RIGHT_BORDER 3
77 #define INDENT_COUNT 5 //without the first two old values
79 #define PIXEL_H_ADJUST( l1, l2 ) PixelHAdjust(l1,l2)
81 #ifdef DEBUGLIN
83 inline long ToMM(Window *pWin, long lVal)
85 return pWin->PixelToLogic(Size(lVal, 0), MapMode(MAP_MM)).Width();
88 void Debug_Impl(Window *pWin, SvxColumnItem& rColItem)
90 String aTmp("Aktuell: ");
91 aTmp += rColItem.GetActColumn();
92 aTmp += " ColLeft: ";
93 aTmp += String(ToMM(pWin, rColItem.GetLeft()));
94 aTmp += " ColRight: ";
95 aTmp += String(ToMM(pWin, rColItem.GetRight()));
96 for(USHORT i = 0; i < rColItem.Count(); ++i) {
97 aTmp += " Start: ";
98 aTmp += String(ToMM(pWin, rColItem[i].nStart));
99 aTmp += " End: ";
100 aTmp += String(ToMM(pWin, rColItem[i].nEnd));
103 InfoBox(0, aTmp).Execute();
106 void Debug_Impl(Window *pWin, const SvxLongLRSpaceItem& rLRSpace)
108 String aTmp("Left: ");
109 aTmp += pWin->PixelToLogic(Size(rLRSpace.GetLeft(), 0), MapMode(MAP_MM)).Width();
110 aTmp += " Right: ";
111 aTmp +=pWin->PixelToLogic(Size(rLRSpace.GetRight(), 0), MapMode(MAP_MM)).Width();
112 InfoBox(0, aTmp).Execute();
115 void Debug_Impl(Window *pWin, const SvxLongULSpaceItem& rULSpace)
117 String aTmp("Upper: ");
118 aTmp += pWin->PixelToLogic(Size(rULSpace.GetUpper(), 0), MapMode(MAP_MM)).Width();
119 aTmp += " Lower: ";
120 aTmp += pWin->PixelToLogic(Size(rULSpace.GetLower(), 0), MapMode(MAP_MM)).Width();
122 InfoBox(0, aTmp).Execute();
125 void DebugTabStops_Impl(const SvxTabStopItem& rTabs)
127 String aTmp("Tabs: ");
129 // Def Tabs loeschen
130 for(USHORT i = 0; i < rTabs.Count(); ++i)
132 aTmp += String(rTabs[i].GetTabPos() / 56);
133 aTmp += " : ";
135 InfoBox(0, aTmp).Execute();
138 void DebugParaMargin_Impl(const SvxLRSpaceItem& rLRSpace)
140 String aTmp("ParaLeft: ");
141 aTmp += rLRSpace.GetTxtLeft() / 56;
142 aTmp += " ParaRight: ";
143 aTmp += rLRSpace.GetRight() / 56;
144 aTmp += " FLI: ";
145 aTmp += rLRSpace.GetTxtFirstLineOfst() / 56;
146 InfoBox(0, aTmp).Execute();
149 #endif // DEBUGLIN
150 #ifdef DEBUG_RULER
151 #include <vcl/svapp.hxx>
152 #include <vcl/lstbox.hxx>
153 class RulerDebugWindow : public Window
155 ListBox aBox;
156 public:
157 RulerDebugWindow(Window* pParent) :
158 Window(pParent, WB_BORDER|WB_SIZEMOVE|WB_DIALOGCONTROL|WB_CLIPCHILDREN|WB_SYSTEMWINDOW),
159 aBox(this, WB_BORDER)
161 Size aOutput(200, 400);
162 SetOutputSizePixel(aOutput);
163 aBox.SetSizePixel(aOutput);
164 aBox.Show();
165 Show();
166 Size aParentSize(pParent->GetOutputSizePixel());
167 Size aOwnSize(GetSizePixel());
168 aParentSize.Width() -= aOwnSize.Width();
169 aParentSize.Height() -= aOwnSize.Height();
170 SetPosPixel(Point(aParentSize.Width(), aParentSize.Height()));
172 ~RulerDebugWindow();
174 ListBox& GetLBox() {return aBox;}
175 static void AddDebugText(const sal_Char* pDescription, const String& rText );
177 static RulerDebugWindow* pDebugWindow = 0;
179 RulerDebugWindow::~RulerDebugWindow()
181 pDebugWindow = 0;
183 void RulerDebugWindow::AddDebugText(const sal_Char* pDescription, const String& rText )
185 if(!pDebugWindow)
187 Window* pParent = Application::GetFocusWindow();
188 while(pParent->GetParent())
189 pParent = pParent->GetParent();
190 pDebugWindow = new RulerDebugWindow(pParent);
192 String sContent(String::CreateFromAscii(pDescription));
193 sContent += rText;
194 USHORT nPos = pDebugWindow->GetLBox().InsertEntry(sContent);
195 pDebugWindow->GetLBox().SelectEntryPos(nPos);
196 pDebugWindow->GrabFocus();
199 #define ADD_DEBUG_TEXT(cDescription, sValue) \
200 RulerDebugWindow::AddDebugText(cDescription, sValue);
202 #define REMOVE_DEBUG_WINDOW \
203 delete pDebugWindow; \
204 pDebugWindow = 0;
206 #else
207 #define ADD_DEBUG_TEXT(cDescription, sValue)
208 #define REMOVE_DEBUG_WINDOW
209 #endif
211 struct SvxRuler_Impl {
212 USHORT *pPercBuf;
213 USHORT *pBlockBuf;
214 USHORT nPercSize;
215 long nTotalDist;
216 long lOldWinPos;
217 long lMaxLeftLogic;
218 long lMaxRightLogic;
219 long lLastLMargin;
220 long lLastRMargin;
221 SvxProtectItem aProtectItem;
222 SfxBoolItem* pTextRTLItem;
223 USHORT nControlerItems;
224 USHORT nIdx;
225 USHORT nColLeftPix, nColRightPix; // Pixelwerte fuer linken / rechten Rand
226 // bei Spalten; gepuffert, um Umrechenfehler
227 // zu vermeiden.
228 // Muesste vielleicht fuer weitere Werte
229 // aufgebohrt werden
230 BOOL bIsTableRows : 1; // pColumnItem contains table rows instead of columns
231 //#i24363# tab stops relative to indent
232 BOOL bIsTabsRelativeToIndent : 1; // Tab stops relative to paragraph indent?
233 SvxRuler_Impl() :
234 pPercBuf(0), pBlockBuf(0),
235 nPercSize(0), nTotalDist(0),
236 lOldWinPos(0),
237 lMaxLeftLogic(0), lMaxRightLogic(0),
238 lLastLMargin(0), lLastRMargin(0),
239 aProtectItem(SID_RULER_PROTECT),
240 pTextRTLItem(0), nControlerItems(0),
241 nIdx(0),
242 nColLeftPix(0), nColRightPix(0),
244 bIsTableRows(FALSE),
245 bIsTabsRelativeToIndent(TRUE)
248 ~SvxRuler_Impl()
250 nPercSize = 0; nTotalDist = 0;
251 delete[] pPercBuf; delete[] pBlockBuf; pPercBuf = 0;
252 delete pTextRTLItem;
254 void SetPercSize(USHORT nSize);
260 void SvxRuler_Impl::SetPercSize(USHORT nSize)
262 if(nSize > nPercSize)
264 delete[] pPercBuf;
265 delete[] pBlockBuf;
266 pPercBuf = new USHORT[nPercSize = nSize];
267 pBlockBuf = new USHORT[nPercSize = nSize];
269 size_t nSize2 = sizeof(USHORT) * nPercSize;
270 memset(pPercBuf, 0, nSize2);
271 memset(pBlockBuf, 0, nSize2);
275 // Konstruktor des Lineals
277 // SID_ATTR_ULSPACE, SID_ATTR_LRSPACE
278 // erwartet als Parameter SvxULSpaceItem f"ur Seitenr"ander
279 // (entweder links/rechts oder oben/unten)
280 // Lineal: SetMargin1, SetMargin2
282 // SID_RULER_PAGE_POS
283 // erwartet als Parameter Anfangswert der Seite sowie Seitenbreite
284 // Lineal: SetPagePos
286 // SID_ATTR_TABSTOP
287 // erwartet: SvxTabStopItem
288 // Lineal: SetTabs
290 // SID_ATTR_PARA_LRSPACE
291 // linker, rechter Absatzrand bei H-Lineal
292 // Lineal: SetIndents
294 // SID_RULER_BORDERS
295 // Tabellenraender, Spalten
296 // erwartet: so etwas wie SwTabCols
297 // Lineal: SetBorders
300 SvxRuler::SvxRuler
302 Window* pParent, // StarView Parent
303 Window* pWin, // Ausgabefenster; wird fuer Umrechnung logische
304 // Einheiten <-> Pixel verwendet
305 USHORT flags, // Anzeige Flags, siehe ruler.hxx
306 SfxBindings &rBindings, // zugeordnete Bindings
307 WinBits nWinStyle // StarView WinBits
309 : Ruler(pParent, nWinStyle),
310 pCtrlItem(new SvxRulerItem *[CTRL_ITEM_COUNT]),
311 pLRSpaceItem(0),
312 pMinMaxItem(0),
313 pULSpaceItem(0),
314 pTabStopItem(0),
315 pParaItem(0),
316 pParaBorderItem(0),
317 pPagePosItem(0),
318 pColumnItem(0),
319 pObjectItem(0),
320 pEditWin(pWin),
321 pRuler_Imp(new SvxRuler_Impl),
322 bAppSetNullOffset(FALSE), //Wird der 0-Offset des Lineals
323 //durch die appl. gesetzt?
324 lLogicNullOffset(0),
325 lAppNullOffset(LONG_MAX),
326 lMinFrame(5),
327 lInitialDragPos(0),
328 nFlags(flags),
329 nDragType(NONE),
330 nDefTabType(RULER_TAB_LEFT),
331 nTabCount(0),
332 nTabBufSize(0),
333 lDefTabDist(50),
334 lTabPos(-1),
335 pTabs(0),
336 pIndents(0),
337 pBorders(new RulerBorder[1]), //wg 1 Spaltiger Tabellen
338 nBorderCount(0),
339 pObjectBorders(0),
340 pBindings(&rBindings),
341 nDragOffset(0),
342 nMaxLeft(0),
343 nMaxRight(0),
344 bValid(FALSE),
345 bListening(FALSE),
346 bActive(TRUE)
349 [Beschreibung]
351 ctor;
352 Datenpuffer initialisieren; ControllerItems werden erzeugt
356 memset(pCtrlItem, 0, sizeof(SvxRulerItem *) * CTRL_ITEM_COUNT);
358 rBindings.EnterRegistrations();
360 // Unterstuetzte Items anlegen
361 USHORT i = 0;
362 // Seitenraender
364 pCtrlItem[i++] = new SvxRulerItem(SID_RULER_LR_MIN_MAX, *this, rBindings);
365 if((nWinStyle & WB_VSCROLL) == WB_VSCROLL)
367 bHorz = FALSE;
368 pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_ULSPACE, *this, rBindings);
370 else
372 bHorz = TRUE;
373 pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_LRSPACE, *this, rBindings);
376 // Seitenposition
377 pCtrlItem[i++] = new SvxRulerItem(SID_RULER_PAGE_POS, *this, rBindings);
379 if((nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS)
381 USHORT nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
382 pCtrlItem[i++] = new SvxRulerItem(nTabStopId, *this, rBindings);
383 SetExtraType(RULER_EXTRA_TAB, nDefTabType);
387 if(0 != (nFlags & (SVXRULER_SUPPORT_PARAGRAPH_MARGINS |SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL)))
389 if(bHorz)
390 pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE, *this, rBindings);
391 else
392 pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE_VERTICAL, *this, rBindings);
393 pIndents = new RulerIndent[5+INDENT_GAP];
394 memset(pIndents, 0, sizeof(RulerIndent)*(3+INDENT_GAP));
395 pIndents[0].nStyle = RULER_STYLE_DONTKNOW;
396 pIndents[1].nStyle = RULER_STYLE_DONTKNOW;
397 pIndents[INDENT_FIRST_LINE].nStyle = RULER_INDENT_TOP;
398 pIndents[INDENT_LEFT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
399 pIndents[INDENT_RIGHT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
400 pIndents[INDENT_LEFT_BORDER].nStyle = RULER_INDENT_BORDER;
401 pIndents[INDENT_RIGHT_BORDER].nStyle = RULER_INDENT_BORDER;
402 for(USHORT nIn = 0; nIn < 7; nIn++)
403 pIndents[nIn].nPos = 0;
406 if((nFlags & SVXRULER_SUPPORT_BORDERS) == SVXRULER_SUPPORT_BORDERS)
408 pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL, *this, rBindings);
409 pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL, *this, rBindings);
412 pCtrlItem[i++] = new SvxRulerItem(SID_RULER_TEXT_RIGHT_TO_LEFT, *this, rBindings);
414 if((nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT)
416 pCtrlItem[i++] = new SvxRulerItem(SID_RULER_OBJECT, *this, rBindings );
417 pObjectBorders = new RulerBorder[OBJECT_BORDER_COUNT];
418 size_t nSize = sizeof( RulerBorder ) * OBJECT_BORDER_COUNT;
419 memset(pObjectBorders, 0, nSize);
420 for(USHORT nBorder = 0; nBorder < OBJECT_BORDER_COUNT; ++nBorder)
422 pObjectBorders[nBorder].nPos = 0;
423 pObjectBorders[nBorder].nWidth = 0;
424 pObjectBorders[nBorder].nStyle = RULER_BORDER_MOVEABLE;
428 pCtrlItem[i++] = new SvxRulerItem( SID_RULER_PROTECT, *this, rBindings );
429 pCtrlItem[i++] = new SvxRulerItem(SID_RULER_BORDER_DISTANCE, *this, rBindings);
430 pRuler_Imp->nControlerItems=i;
432 if((nFlags & SVXRULER_SUPPORT_SET_NULLOFFSET) ==
433 SVXRULER_SUPPORT_SET_NULLOFFSET)
434 SetExtraType(RULER_EXTRA_NULLOFFSET, 0);
436 rBindings.LeaveRegistrations();
440 __EXPORT SvxRuler::~SvxRuler()
442 [Beschreibung]
444 Destruktor Lineal
445 Freigabe interner Puffer
450 REMOVE_DEBUG_WINDOW
451 if(bListening)
452 EndListening(*pBindings);
454 pBindings->EnterRegistrations();
456 for(USHORT i = 0; i < CTRL_ITEM_COUNT && pCtrlItem[i]; ++i)
457 delete pCtrlItem[i];
458 delete[] pCtrlItem;
460 delete pLRSpaceItem;
461 delete pMinMaxItem;
462 delete pULSpaceItem;
463 delete pTabStopItem;
464 delete pParaItem;
465 delete pParaBorderItem;
466 delete pPagePosItem;
467 delete pColumnItem;
468 delete pObjectItem;
469 delete[] pIndents;
470 delete[] pBorders;
471 delete[] pObjectBorders;
472 delete[] pTabs;
473 delete pRuler_Imp;
475 pBindings->LeaveRegistrations();
480 [Beschreibung]
482 Interne Umrechenroutinen
486 long SvxRuler::ConvertHPosPixel(long nVal) const
488 return pEditWin->LogicToPixel(Size(nVal, 0)).Width();
491 long SvxRuler::ConvertVPosPixel(long nVal) const
493 return pEditWin->LogicToPixel(Size(0, nVal)).Height();
496 long SvxRuler::ConvertHSizePixel(long nVal) const
498 return pEditWin->LogicToPixel(Size(nVal, 0)).Width();
501 long SvxRuler::ConvertVSizePixel(long nVal) const
503 return pEditWin->LogicToPixel(Size(0, nVal)).Height();
506 long SvxRuler::ConvertPosPixel(long nVal) const
508 return bHorz ? ConvertHPosPixel(nVal): ConvertVPosPixel(nVal);
511 long SvxRuler::ConvertSizePixel(long nVal) const
513 return bHorz? ConvertHSizePixel(nVal): ConvertVSizePixel(nVal);
517 inline long SvxRuler::ConvertHPosLogic(long nVal) const
519 return pEditWin->PixelToLogic(Size(nVal, 0)).Width();
522 inline long SvxRuler::ConvertVPosLogic(long nVal) const
524 return pEditWin->PixelToLogic(Size(0, nVal)).Height();
527 inline long SvxRuler::ConvertHSizeLogic(long nVal) const
529 return pEditWin->PixelToLogic(Size(nVal, 0)).Width();
532 inline long SvxRuler::ConvertVSizeLogic(long nVal) const
534 return pEditWin->PixelToLogic(Size(0, nVal)).Height();
537 inline long SvxRuler::ConvertPosLogic(long nVal) const
539 return bHorz? ConvertHPosLogic(nVal): ConvertVPosLogic(nVal);
542 inline long SvxRuler::ConvertSizeLogic(long nVal) const
544 return bHorz? ConvertHSizeLogic(nVal): ConvertVSizeLogic(nVal);
547 long SvxRuler::PixelHAdjust(long nVal, long nValOld) const
549 if(ConvertHSizePixel(nVal)!=ConvertHSizePixel(nValOld))
550 return nVal;
551 else
552 return nValOld;
555 long SvxRuler::PixelVAdjust(long nVal, long nValOld) const
557 if(ConvertVSizePixel(nVal)!=ConvertVSizePixel(nValOld))
558 return nVal;
559 else
560 return nValOld;
563 long SvxRuler::PixelAdjust(long nVal, long nValOld) const
565 if(ConvertSizePixel(nVal)!=ConvertSizePixel(nValOld))
566 return nVal;
567 else
568 return nValOld;
572 inline USHORT SvxRuler::GetObjectBordersOff(USHORT nIdx) const
574 return bHorz? nIdx: nIdx + 2;
579 void SvxRuler::UpdateFrame()
582 [Beschreibung]
584 Linken, oberen Rand aktualisieren
585 Items werden in die Darstellung des Lineals uebersetzt.
590 const USHORT nMarginStyle =
591 ( pRuler_Imp->aProtectItem.IsSizeProtected() ||
592 pRuler_Imp->aProtectItem.IsPosProtected() ) ?
593 0 : RULER_MARGIN_SIZEABLE;
595 if(pLRSpaceItem && pPagePosItem)
597 // wenn keine Initialisierung durch App Defaultverhalten
598 const long nOld = lLogicNullOffset;
599 lLogicNullOffset = pColumnItem?
600 pColumnItem->GetLeft(): pLRSpaceItem->GetLeft();
601 if(bAppSetNullOffset)
602 lAppNullOffset += lLogicNullOffset - nOld;
603 if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX)
605 Ruler::SetNullOffset(ConvertHPosPixel(lLogicNullOffset));
606 SetMargin1( 0, nMarginStyle );
607 lAppNullOffset = 0;
609 else
610 SetMargin1( ConvertHPosPixel( lAppNullOffset ), nMarginStyle );
611 long lRight = 0;
612 // bei Tabelle rechten Rand der Tabelle auswerten
613 if(pColumnItem && pColumnItem->IsTable())
614 lRight = pColumnItem->GetRight();
615 else
616 lRight = pLRSpaceItem->GetRight();
618 ULONG aWidth=
619 ConvertHPosPixel(pPagePosItem->GetWidth() - lRight -
620 lLogicNullOffset + lAppNullOffset);
621 SetMargin2( aWidth, nMarginStyle );
623 else
624 if(pULSpaceItem && pPagePosItem)
626 // Nullpunkt aus oberem Rand des umgebenden Rahmens
627 const long nOld = lLogicNullOffset;
628 lLogicNullOffset = pColumnItem?
629 pColumnItem->GetLeft(): pULSpaceItem->GetUpper();
630 if(bAppSetNullOffset)
631 lAppNullOffset += lLogicNullOffset - nOld;
632 if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX) {
633 Ruler::SetNullOffset(ConvertVPosPixel(lLogicNullOffset));
634 lAppNullOffset = 0;
635 SetMargin1( 0, nMarginStyle );
637 else
638 SetMargin1( ConvertVPosPixel( lAppNullOffset ),nMarginStyle );
640 long lLower = pColumnItem ?
641 pColumnItem->GetRight() : pULSpaceItem->GetLower();
643 SetMargin2(ConvertVPosPixel(pPagePosItem->GetHeight() - lLower -
644 lLogicNullOffset + lAppNullOffset),
645 nMarginStyle );
647 else
649 // schaltet die Anzeige aus
650 SetMargin1();
651 SetMargin2();
653 if(pColumnItem)
655 pRuler_Imp->nColLeftPix = (USHORT) ConvertSizePixel(pColumnItem->GetLeft());
656 pRuler_Imp->nColRightPix = (USHORT) ConvertSizePixel(pColumnItem->GetRight());
661 void SvxRuler::MouseMove( const MouseEvent& rMEvt )
663 if( bActive )
665 pBindings->Update( SID_RULER_LR_MIN_MAX );
666 pBindings->Update( SID_ATTR_LONG_ULSPACE );
667 pBindings->Update( SID_ATTR_LONG_LRSPACE );
668 pBindings->Update( SID_RULER_PAGE_POS );
669 pBindings->Update( bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL);
670 pBindings->Update( bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL);
671 pBindings->Update( bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
672 pBindings->Update( bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL);
673 pBindings->Update( SID_RULER_OBJECT );
674 pBindings->Update( SID_RULER_PROTECT );
676 Ruler::MouseMove( rMEvt );
678 void SvxRuler::StartListening_Impl()
680 if(!bListening)
682 bValid = FALSE;
683 StartListening(*pBindings);
684 bListening = TRUE;
688 void SvxRuler::UpdateFrame
690 const SvxLongLRSpaceItem *pItem // neuer Wert LRSpace
694 [Beschreibung]
696 Neuen Wert fuer LRSpace merken; alten gfs. loeschen
701 if(bActive)
703 delete pLRSpaceItem; pLRSpaceItem = 0;
704 if(pItem)
705 pLRSpaceItem = new SvxLongLRSpaceItem(*pItem);
706 StartListening_Impl();
711 void SvxRuler::UpdateFrameMinMax
713 const SfxRectangleItem *pItem // Werte fuer MinMax
717 [Beschreibung]
719 Neuen Wert fuer MinMax setzen; alten gfs. loeschen
724 if(bActive)
726 delete pMinMaxItem; pMinMaxItem = 0;
727 if(pItem)
728 pMinMaxItem = new SfxRectangleItem(*pItem);
733 void SvxRuler::UpdateFrame
735 const SvxLongULSpaceItem *pItem // neuer Wert
739 [Beschreibung]
741 Rechten / unteren Rand aktualisieren
747 if(bActive && !bHorz)
749 delete pULSpaceItem; pULSpaceItem = 0;
750 if(pItem)
751 pULSpaceItem = new SvxLongULSpaceItem(*pItem);
752 StartListening_Impl();
756 void SvxRuler::Update( const SvxProtectItem* pItem )
758 if( pItem ) pRuler_Imp->aProtectItem = *pItem;
760 /* -----------------------------22.08.2002 13:10------------------------------
762 ---------------------------------------------------------------------------*/
763 void SvxRuler::UpdateTextRTL(const SfxBoolItem* pItem)
765 if(bActive && bHorz)
767 delete pRuler_Imp->pTextRTLItem; pRuler_Imp->pTextRTLItem = 0;
768 if(pItem)
769 pRuler_Imp->pTextRTLItem = new SfxBoolItem(*pItem);
770 SetTextRTL(pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue());
771 StartListening_Impl();
775 void SvxRuler::Update
777 const SvxColumnItem *pItem, // neuer Wert
778 USHORT nSID //Slot Id to identify NULL items
782 [Beschreibung]
784 Neuen Wert fuer Spaltendarstellung setzen
789 if(bActive)
791 if(pItem)
793 delete pColumnItem; pColumnItem = 0;
794 pRuler_Imp->bIsTableRows = (pItem->Which() == SID_RULER_ROWS || pItem->Which() == SID_RULER_ROWS_VERTICAL);
795 pColumnItem = new SvxColumnItem(*pItem);
796 if(!bHorz && !pRuler_Imp->bIsTableRows)
797 pColumnItem->SetWhich(SID_RULER_BORDERS_VERTICAL);
799 else if(pColumnItem && pColumnItem->Which() == nSID)
800 //there are two groups of column items table/frame columns and table rows
801 //both can occur in vertical or horizontal mode
802 //the horizontal ruler handles the SID_RULER_BORDERS and SID_RULER_ROWS_VERTICAL
803 //and the vertical handles SID_RULER_BORDERS_VERTICAL and SID_RULER_ROWS
804 //if pColumnItem is already set with one of the ids then a NULL pItem argument
805 //must not delete it
807 delete pColumnItem; pColumnItem = 0;
808 pRuler_Imp->bIsTableRows = FALSE;
810 StartListening_Impl();
815 void SvxRuler::UpdateColumns()
817 [Beschreibung]
819 Anzeige der Spaltendarstellung aktualisieren
823 if(pColumnItem && pColumnItem->Count() > 1)
825 if( nBorderCount < pColumnItem->Count())
827 delete[] pBorders;
828 nBorderCount = pColumnItem->Count();
829 pBorders = new RulerBorder[nBorderCount];
831 USHORT _nFlags = RULER_BORDER_VARIABLE;
832 BOOL bProtectColumns =
833 pRuler_Imp->aProtectItem.IsSizeProtected() ||
834 pRuler_Imp->aProtectItem.IsPosProtected();
835 if( !bProtectColumns )
836 _nFlags |= RULER_BORDER_MOVEABLE;
837 if( pColumnItem->IsTable() )
838 _nFlags |= RULER_BORDER_TABLE;
839 else
840 if ( !bProtectColumns )
841 _nFlags |= RULER_BORDER_SIZEABLE;
843 USHORT nBorders = pColumnItem->Count();
844 if(!pRuler_Imp->bIsTableRows)
845 --nBorders;
846 for(USHORT i = 0; i < nBorders; ++i)
848 pBorders[i].nStyle = _nFlags;
849 if(!(*pColumnItem)[i].bVisible)
850 pBorders[i].nStyle |= RULER_STYLE_INVISIBLE;
851 pBorders[i].nPos =
852 ConvertPosPixel((*pColumnItem)[i].nEnd + lAppNullOffset);
853 if(pColumnItem->Count() == i + 1)
855 //with table rows the end of the table is contained in the
856 //column item but it has no width!
857 pBorders[i].nWidth = 0;
859 else
861 pBorders[i].nWidth =
862 ConvertSizePixel((*pColumnItem)[i+1].nStart -
863 (*pColumnItem)[i].nEnd);
865 pBorders[i].nMinPos =
866 ConvertPosPixel((*pColumnItem)[i].nEndMin + lAppNullOffset);
867 pBorders[i].nMaxPos =
868 ConvertPosPixel((*pColumnItem)[i].nEndMax + lAppNullOffset);
870 SetBorders(pColumnItem->Count()-1, pBorders);
872 else
874 SetBorders();
879 void SvxRuler::UpdateObject()
882 [Beschreibung]
884 Anzeige der Objektdarstellung aktualisieren
889 if(pObjectItem)
891 DBG_ASSERT(pObjectBorders, "kein Buffer");
892 // !! zum Seitenrand
893 long nMargin = pLRSpaceItem? pLRSpaceItem->GetLeft(): 0;
894 pObjectBorders[0].nPos =
895 ConvertPosPixel(pObjectItem->GetStartX() -
896 nMargin + lAppNullOffset);
897 pObjectBorders[1].nPos =
898 ConvertPosPixel(pObjectItem->GetEndX() - nMargin + lAppNullOffset);
899 nMargin = pULSpaceItem? pULSpaceItem->GetUpper(): 0;
900 pObjectBorders[2].nPos =
901 ConvertPosPixel(pObjectItem->GetStartY() -
902 nMargin + lAppNullOffset);
903 pObjectBorders[3].nPos =
904 ConvertPosPixel(pObjectItem->GetEndY() - nMargin + lAppNullOffset);
906 const USHORT nOff = GetObjectBordersOff(0);
907 SetBorders(2, pObjectBorders + nOff);
909 else
911 SetBorders();
916 void SvxRuler::UpdatePara()
919 [Beschreibung]
921 Anzeige der Absatzeinzuege aktualisieren:
922 Linken Rand, Erstzeileneinzug, rechten Rand Absatz aktualisieren
923 pIndents[0] = Buffer fuer alten Einzug
924 pIndents[1] = Buffer fuer alten Einzug
925 pIndents[INDENT_FIRST_LINE] = Erstzeileneinzug
926 pIndents[3] = linker Rand
927 pIndents[4] = rechter Rand
928 pIndents[5] = left border distance
929 pIndents[6] = right border distance
934 // Abhaengigkeit zu PagePosItem
935 if(pParaItem && pPagePosItem && !pObjectItem)
937 BOOL bRTLText = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
938 // Erstzeileneinzug, ist negativ zum linken Absatzrand
939 long nLeftFrameMargin = GetLeftFrameMargin();
940 long nRightFrameMargin = GetRightFrameMargin();
941 if(bRTLText)
942 pIndents[INDENT_FIRST_LINE].nPos =
943 ConvertHPosPixel(
944 nRightFrameMargin -
945 pParaItem->GetTxtLeft() -
946 pParaItem->GetTxtFirstLineOfst() + lAppNullOffset );
947 else
948 pIndents[INDENT_FIRST_LINE].nPos =
949 ConvertHPosPixel(
950 nLeftFrameMargin +
951 pParaItem->GetTxtLeft() +
952 pParaItem->GetTxtFirstLineOfst() +
953 lAppNullOffset);
954 if( pParaItem->IsAutoFirst() )
955 pIndents[INDENT_FIRST_LINE].nStyle |= RULER_STYLE_INVISIBLE;
956 else
957 pIndents[INDENT_FIRST_LINE].nStyle &= ~RULER_STYLE_INVISIBLE;
959 if(bRTLText)
961 // left margin
962 pIndents[INDENT_LEFT_MARGIN].nPos =
963 ConvertHPosPixel(
964 nRightFrameMargin -
965 pParaItem->GetTxtLeft() + lAppNullOffset);
966 // right margin
967 pIndents[INDENT_RIGHT_MARGIN].nPos =
968 ConvertHPosPixel(
969 nLeftFrameMargin +
970 pParaItem->GetRight() + lAppNullOffset);
972 else
974 // linker Rand
975 pIndents[INDENT_LEFT_MARGIN].nPos =
976 ConvertHPosPixel(
977 nLeftFrameMargin +
978 pParaItem->GetTxtLeft() + lAppNullOffset);
979 // rechter Rand, immer negativ zum rechten Rand des umgebenden Frames
980 pIndents[INDENT_RIGHT_MARGIN].nPos =
981 ConvertHPosPixel(
982 nRightFrameMargin -
983 pParaItem->GetRight() + lAppNullOffset);
985 if(pParaBorderItem)
987 pIndents[INDENT_LEFT_BORDER].nPos =
988 ConvertHPosPixel( nLeftFrameMargin + lAppNullOffset);
989 pIndents[INDENT_RIGHT_BORDER].nPos =
990 ConvertHPosPixel(nRightFrameMargin - lAppNullOffset);
991 pIndents[INDENT_LEFT_BORDER].nStyle = pIndents[INDENT_RIGHT_BORDER].nStyle &= ~RULER_STYLE_INVISIBLE;
993 else
994 pIndents[INDENT_LEFT_BORDER].nStyle = pIndents[INDENT_RIGHT_BORDER].nStyle |= RULER_STYLE_INVISIBLE;
996 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
998 else
1000 if(pIndents)
1002 pIndents[INDENT_FIRST_LINE].nPos =
1003 pIndents[INDENT_LEFT_MARGIN].nPos =
1004 pIndents[INDENT_RIGHT_MARGIN].nPos = 0;
1006 SetIndents(); // ausschalten
1011 void SvxRuler::UpdatePara
1013 const SvxLRSpaceItem *pItem // neuer Wert Absatzeinzuege
1017 [Beschreibung]
1019 Neuen Wert Absatzeinzuege merken
1023 if(bActive)
1025 delete pParaItem; pParaItem = 0;
1026 if(pItem)
1027 pParaItem = new SvxLRSpaceItem(*pItem);
1028 StartListening_Impl();
1031 void SvxRuler::UpdateParaBorder(const SvxLRSpaceItem * pItem )
1033 [Description]
1034 Border distance
1038 if(bActive)
1040 delete pParaBorderItem; pParaBorderItem = 0;
1041 if(pItem)
1042 pParaBorderItem = new SvxLRSpaceItem(*pItem);
1043 StartListening_Impl();
1048 void SvxRuler::UpdatePage()
1051 [Beschreibung]
1053 Anzeige von Postion und Breite der Seite aktualisieren
1058 if(pPagePosItem)
1060 // alle Objekte werden automatisch angepasst
1061 if(bHorz)
1062 SetPagePos(
1063 pEditWin->LogicToPixel(pPagePosItem->GetPos()).X(),
1064 pEditWin->LogicToPixel(Size(pPagePosItem->GetWidth(),0)).
1065 Width());
1066 else
1067 SetPagePos(
1068 pEditWin->LogicToPixel(pPagePosItem->GetPos()).Y(),
1069 pEditWin->LogicToPixel(Size(0, pPagePosItem->GetHeight())).
1070 Height());
1071 if(bAppSetNullOffset)
1072 SetNullOffset(ConvertSizePixel(-lAppNullOffset + lLogicNullOffset));
1074 else
1075 SetPagePos();
1077 long lPos = 0;
1078 Point aOwnPos = GetPosPixel();
1079 Point aEdtWinPos = pEditWin->GetPosPixel();
1080 if( Application::GetSettings().GetLayoutRTL() && bHorz )
1082 //#i73321# in RTL the window and the ruler is not mirrored but the
1083 // influence of the vertical ruler is inverted
1084 Size aOwnSize = GetSizePixel();
1085 Size aEdtWinSize = pEditWin->GetSizePixel();
1086 lPos = aOwnSize.Width() - aEdtWinSize.Width();
1087 lPos -= (aEdtWinPos - aOwnPos).X();
1089 else
1091 Point aPos(aEdtWinPos - aOwnPos);
1092 lPos= bHorz ? aPos.X() : aPos.Y();
1095 // Leider bekommen wir den Offset des Editfensters zum Lineal nie
1096 // per Statusmeldung. Also setzen wir ihn selbst, wenn noetig.
1098 if(lPos!=pRuler_Imp->lOldWinPos)
1100 pRuler_Imp->lOldWinPos=lPos;
1101 SetWinPos(lPos);
1106 void SvxRuler::Update
1108 const SvxPagePosSizeItem *pItem // neuer Wert Seitenattribute
1112 [Beschreibung]
1114 Neuen Wert Seitenattribute merken
1119 if(bActive)
1121 delete pPagePosItem; pPagePosItem = 0;
1122 if(pItem)
1123 pPagePosItem = new SvxPagePosSizeItem(*pItem);
1124 StartListening_Impl();
1131 void SvxRuler::SetDefTabDist
1133 long l // Neuer Abstand fuer DefaultTabs in App-Metrik
1137 [Beschreibung]
1139 Neuer Abstand fuer DefaultTabs wird gesetzt
1145 lDefTabDist = l;
1146 UpdateTabs();
1150 long SvxRuler::GetDefTabDist() const
1153 [Beschreibung]
1155 Wert fuer DefaultTabs erfragen (wird in App.-Methik geliefert)
1160 return lDefTabDist;
1164 USHORT ToSvTab_Impl(SvxTabAdjust eAdj)
1167 [Beschreibung]
1169 Interne Konvertierungsroutinen zwischen SV-Tab.-Enum und Svx
1174 switch(eAdj) {
1175 case SVX_TAB_ADJUST_LEFT: return RULER_TAB_LEFT;
1176 case SVX_TAB_ADJUST_RIGHT: return RULER_TAB_RIGHT;
1177 case SVX_TAB_ADJUST_DECIMAL: return RULER_TAB_DECIMAL;
1178 case SVX_TAB_ADJUST_CENTER: return RULER_TAB_CENTER;
1179 case SVX_TAB_ADJUST_DEFAULT: return RULER_TAB_DEFAULT;
1180 default: ;//prevent warning
1182 return 0;
1186 SvxTabAdjust ToAttrTab_Impl(USHORT eAdj)
1188 switch(eAdj) {
1189 case RULER_TAB_LEFT: return SVX_TAB_ADJUST_LEFT ;
1190 case RULER_TAB_RIGHT: return SVX_TAB_ADJUST_RIGHT ;
1191 case RULER_TAB_DECIMAL: return SVX_TAB_ADJUST_DECIMAL ;
1192 case RULER_TAB_CENTER: return SVX_TAB_ADJUST_CENTER ;
1193 case RULER_TAB_DEFAULT: return SVX_TAB_ADJUST_DEFAULT ;
1195 return SVX_TAB_ADJUST_LEFT;
1199 void SvxRuler::UpdateTabs()
1202 [Beschreibung]
1204 Anzeige der Tabulatoren
1209 if(IsDrag())
1210 return;
1211 if(pPagePosItem && pParaItem && pTabStopItem && !pObjectItem)
1213 // Puffer fuer DefaultTabStop
1214 // Abstand letzter Tab <-> Rechter Absatzrand / DefaultTabDist
1215 BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
1216 long nLeftFrameMargin = GetLeftFrameMargin();
1217 long nRightFrameMargin = GetRightFrameMargin();
1219 //#i24363# tab stops relative to indent
1220 const long nParaItemTxtLeft = pRuler_Imp->bIsTabsRelativeToIndent ?
1221 pParaItem->GetTxtLeft() :
1224 const long lParaIndent = nLeftFrameMargin + nParaItemTxtLeft;
1226 const long lLastTab =
1227 pTabStopItem->Count()?
1228 ConvertHPosPixel((*pTabStopItem)[pTabStopItem->Count()-1].GetTabPos()): 0;
1229 const long lPosPixel =
1230 ConvertHPosPixel(lParaIndent) + lLastTab;
1231 const long lRightIndent =
1232 ConvertHPosPixel(nRightFrameMargin - pParaItem->GetRight());
1233 long nDefTabDist = ConvertHPosPixel(lDefTabDist);
1234 if( !nDefTabDist )
1235 nDefTabDist = 1;
1236 const USHORT nDefTabBuf = lPosPixel > lRightIndent ||
1237 lLastTab > lRightIndent
1239 : (USHORT)( (lRightIndent - lPosPixel) / nDefTabDist );
1241 if(pTabStopItem->Count() + TAB_GAP + nDefTabBuf > nTabBufSize)
1243 delete[] pTabs;
1244 // 10 (GAP) auf Vorrat
1245 nTabBufSize = pTabStopItem->Count() + TAB_GAP + nDefTabBuf + GAP;
1246 pTabs = new RulerTab[nTabBufSize];
1249 nTabCount = 0;
1250 USHORT j;
1251 //#i24363# tab stops relative to indent
1252 const long lRightPixMargin = ConvertSizePixel(nRightFrameMargin - nParaItemTxtLeft );
1253 const long lParaIndentPix = ConvertSizePixel(lParaIndent);
1254 for(j = 0; j < pTabStopItem->Count(); ++j)
1256 const SvxTabStop *pTab = &(*pTabStopItem)[j];
1257 pTabs[nTabCount+TAB_GAP].nPos =
1258 ConvertHPosPixel(
1259 lParaIndent + pTab->GetTabPos() + lAppNullOffset);
1260 if(bRTL)
1262 pTabs[nTabCount+TAB_GAP].nPos = lParaIndentPix + lRightPixMargin - pTabs[nTabCount+TAB_GAP].nPos;
1264 pTabs[nTabCount+TAB_GAP].nStyle = ToSvTab_Impl(pTab->GetAdjustment());
1265 ++nTabCount;
1267 if(!pTabStopItem->Count())
1268 pTabs[0].nPos = bRTL ? lRightPixMargin : lParaIndentPix;
1270 // Rest mit Default-Tabs fuellen
1271 if(bRTL)
1273 for(j = 0; j < nDefTabBuf; ++j)
1275 pTabs[nTabCount + TAB_GAP].nPos =
1276 pTabs[nTabCount].nPos - nDefTabDist;
1278 if(j == 0 )
1279 pTabs[nTabCount + TAB_GAP].nPos -=
1280 ((pTabs[nTabCount + TAB_GAP].nPos - lRightPixMargin)
1281 % nDefTabDist );
1282 if(pTabs[nTabCount+TAB_GAP].nPos <= lParaIndentPix)
1283 break;
1284 pTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
1285 ++nTabCount;
1288 else
1290 for(j = 0; j < nDefTabBuf; ++j)
1292 pTabs[nTabCount + TAB_GAP].nPos =
1293 pTabs[nTabCount].nPos + nDefTabDist;
1295 if(j == 0 )
1296 pTabs[nTabCount + TAB_GAP].nPos -=
1297 ((pTabs[nTabCount + TAB_GAP].nPos - lParaIndentPix)
1298 % nDefTabDist );
1299 if(pTabs[nTabCount+TAB_GAP].nPos >= lRightIndent)
1300 break;
1301 pTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
1302 ++nTabCount;
1305 SetTabs(nTabCount, pTabs+TAB_GAP);
1306 DBG_ASSERT(nTabCount + TAB_GAP <= nTabBufSize, "BufferSize zu klein");
1308 else
1310 SetTabs();
1315 void SvxRuler::Update
1317 const SvxTabStopItem *pItem // Neuer Wert fuer Tabulatoren
1321 [Beschreibung]
1323 Neuen Wert fuer Tabulatoren merken; alten gfs. loeschen
1328 if(bActive)
1330 delete pTabStopItem; pTabStopItem = 0;
1331 if(pItem)
1333 pTabStopItem = new SvxTabStopItem(*pItem);
1334 if(!bHorz)
1335 pTabStopItem->SetWhich(SID_ATTR_TABSTOP_VERTICAL);
1337 StartListening_Impl();
1342 void SvxRuler::Update
1344 const SvxObjectItem *pItem // Neuer Wert fuer Objekte
1348 [Beschreibung]
1350 Neuen Wert fuer Objekte merken
1355 if(bActive)
1357 delete pObjectItem; pObjectItem = 0;
1358 if(pItem)
1359 pObjectItem = new SvxObjectItem(*pItem);
1360 StartListening_Impl();
1365 void SvxRuler::SetNullOffsetLogic
1367 long lVal // Setzen des logischen NullOffsets
1370 lAppNullOffset = lLogicNullOffset - lVal;
1371 bAppSetNullOffset = TRUE;
1372 Ruler::SetNullOffset(ConvertSizePixel(lVal));
1373 Update();
1377 void SvxRuler::Update()
1380 [Beschreibung]
1382 Aktualisierung der Anzeige anstossen
1387 if(IsDrag())
1388 return;
1389 UpdatePage();
1390 UpdateFrame();
1391 if((nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT)
1392 UpdateObject();
1393 else
1394 UpdateColumns();
1396 if(0 != (nFlags & (SVXRULER_SUPPORT_PARAGRAPH_MARGINS |SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL)))
1397 UpdatePara();
1398 if(0 != (nFlags & SVXRULER_SUPPORT_TABS))
1399 UpdateTabs();
1403 inline long SvxRuler::GetPageWidth() const
1405 return bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
1410 inline long SvxRuler::GetFrameLeft() const
1413 [Beschreibung]
1415 Erfragen des linken Randes in Pixeln
1421 return bAppSetNullOffset?
1422 GetMargin1() + ConvertSizePixel(lLogicNullOffset):
1423 Ruler::GetNullOffset();
1426 inline void SvxRuler::SetFrameLeft(long l)
1429 [Beschreibung]
1431 Setzen des linken Randes in Pixeln
1436 BOOL bProtectColumns =
1437 pRuler_Imp->aProtectItem.IsSizeProtected() ||
1438 pRuler_Imp->aProtectItem.IsPosProtected();
1439 if(bAppSetNullOffset)
1440 SetMargin1(l - ConvertSizePixel(lLogicNullOffset),
1441 bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE);
1442 else
1443 Ruler::SetNullOffset(l);
1447 long SvxRuler::GetFirstLineIndent() const
1450 [Beschreibung]
1452 Erstzeileneinzug in Pixels erfragen
1456 return pParaItem? pIndents[INDENT_FIRST_LINE].nPos: GetMargin1();
1460 long SvxRuler::GetLeftIndent() const
1463 [Beschreibung]
1465 Linken Absatzrand in Pixels erfragen
1469 return pParaItem? pIndents[INDENT_LEFT_MARGIN].nPos: GetMargin1();
1474 long SvxRuler::GetRightIndent() const
1477 [Beschreibung]
1479 Rechten Absatzrand in Pixels erfragen
1483 return pParaItem? pIndents[INDENT_RIGHT_MARGIN].nPos: GetMargin2();
1487 long SvxRuler::GetLogicRightIndent() const
1490 [Beschreibung]
1492 Rechten Absatzrand in Logic erfragen
1496 return pParaItem ? GetRightFrameMargin()-pParaItem->GetRight() : GetRightFrameMargin();
1499 // linker Rand in App-Werten; ist entweder der Seitenrand (=0)
1500 // oder der linke Rand der Spalte, die im Spaltenattribut als
1501 // altuelle Spalte eingestellt ist.
1503 long SvxRuler::GetLeftFrameMargin() const
1505 // #126721# for some unknown reason the current column is set to 0xffff
1506 DBG_ASSERT(!pColumnItem || pColumnItem->GetActColumn() < pColumnItem->Count(),
1507 "issue #126721# - invalid current column!");
1508 long nLeft =
1509 pColumnItem && pColumnItem->Count() && pColumnItem->GetActColumn() < pColumnItem->Count() ?
1510 (*pColumnItem)[pColumnItem->GetActColumn()].nStart : 0;
1511 if(pParaBorderItem && (!pColumnItem || pColumnItem->IsTable()))
1512 nLeft += pParaBorderItem->GetLeft();
1513 return nLeft;
1516 inline long SvxRuler::GetLeftMin() const
1518 DBG_ASSERT(pMinMaxItem, "kein MinMax-Wert gesetzt");
1519 return pMinMaxItem?
1520 bHorz? pMinMaxItem->GetValue().Left(): pMinMaxItem->GetValue().Top()
1521 : 0;
1524 inline long SvxRuler::GetRightMax() const
1526 DBG_ASSERT(pMinMaxItem, "kein MinMax-Wert gesetzt");
1527 return pMinMaxItem?
1528 bHorz? pMinMaxItem->GetValue().Right(): pMinMaxItem->GetValue().Bottom()
1529 : 0;
1533 long SvxRuler::GetRightFrameMargin() const
1536 [Beschreibung]
1538 Rechten umgebenden Rand erfragen (in logischen Einheiten)
1543 if(pColumnItem)
1545 if(!IsActLastColumn( TRUE ))
1547 long nRet = (*pColumnItem)[GetActRightColumn( TRUE )].nEnd;
1548 if(pColumnItem->IsTable() && pParaBorderItem)
1549 nRet -= pParaBorderItem->GetRight();
1550 return nRet;
1554 long l = lLogicNullOffset;
1556 // gfs. rechten Tabelleneinzug abziehen
1557 if(pColumnItem && pColumnItem->IsTable())
1558 l += pColumnItem->GetRight();
1559 else if(bHorz && pLRSpaceItem)
1560 l += pLRSpaceItem->GetRight();
1561 else if(!bHorz && pULSpaceItem)
1562 l += pULSpaceItem->GetLower();
1564 if(pParaBorderItem &&
1565 (!pColumnItem || pColumnItem->IsTable()||IsActLastColumn( TRUE )))
1566 l += pParaBorderItem->GetRight();
1568 if(bHorz)
1569 l = pPagePosItem->GetWidth() - l;
1570 else
1571 l = pPagePosItem->GetHeight() - l;
1572 return l;
1575 #define NEG_FLAG ( (nFlags & SVXRULER_SUPPORT_NEGATIVE_MARGINS) == \
1576 SVXRULER_SUPPORT_NEGATIVE_MARGINS )
1577 #define TAB_FLAG ( pColumnItem && pColumnItem->IsTable() )
1579 long SvxRuler::GetCorrectedDragPos( BOOL bLeft, BOOL bRight )
1582 [Beschreibung]
1584 Korrigiert die Position innerhalb der errechneten Grenzwerte.
1585 Die Grenzwerte sind in Pixel relativ zum Seitenrand.
1590 const long lNullPix = Ruler::GetNullOffset();
1591 long lDragPos = GetDragPos() + lNullPix;
1592 ADD_DEBUG_TEXT("lDragPos: ", String::CreateFromInt32(lDragPos))
1593 BOOL bHoriRows = bHorz && pRuler_Imp->bIsTableRows;
1594 if((bLeft || (bHoriRows)) && lDragPos < nMaxLeft)
1595 lDragPos = nMaxLeft;
1596 else if((bRight||bHoriRows) && lDragPos > nMaxRight)
1597 lDragPos = nMaxRight;
1598 return lDragPos - lNullPix;
1603 void ModifyTabs_Impl
1605 USHORT nCount, // Anzahl Tabs
1606 RulerTab *pTabs, // Tab-Puffer
1607 long lDiff // zu addierende Differenz
1611 [Beschreibung]
1613 Hilfsroutine; alle Tabs um einen festen Wert verschieben
1617 if( pTabs )
1618 for(USHORT i = 0; i < nCount; ++i) pTabs[i].nPos += lDiff;
1623 void SvxRuler::DragMargin1()
1626 [Beschreibung]
1628 Draggen des linken Frame-Randes
1632 const long lDragPos = GetCorrectedDragPos( !TAB_FLAG || !NEG_FLAG, TRUE );
1633 DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 3 : 7, bHorz);
1634 if(pColumnItem&&
1635 (//nDragType & DRAG_OBJECT_SIZE_LINEAR ||
1636 nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL))
1637 DragBorders();
1638 AdjustMargin1(lDragPos);
1640 void SvxRuler::AdjustMargin1(long lDiff)
1642 const long nOld = bAppSetNullOffset? GetMargin1(): GetNullOffset();
1643 const long lDragPos = lDiff;
1644 BOOL bProtectColumns =
1645 pRuler_Imp->aProtectItem.IsSizeProtected() ||
1646 pRuler_Imp->aProtectItem.IsPosProtected();
1648 const USHORT nMarginStyle =
1649 bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE;
1651 if(!bAppSetNullOffset)
1653 long _lDiff = lDragPos;
1654 SetNullOffset(nOld + _lDiff);
1655 if(!pColumnItem||!(nDragType & DRAG_OBJECT_SIZE_LINEAR))
1657 SetMargin2( GetMargin2() - _lDiff, nMarginStyle );
1659 if(!pColumnItem && !pObjectItem && pParaItem)
1661 // Rechten Einzug an alter Position
1662 pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
1663 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1665 if(pObjectItem)
1667 pObjectBorders[GetObjectBordersOff(0)].nPos -= _lDiff;
1668 pObjectBorders[GetObjectBordersOff(1)].nPos -= _lDiff;
1669 SetBorders(2, pObjectBorders + GetObjectBordersOff(0));
1671 if(pColumnItem)
1673 for(USHORT i = 0; i < pColumnItem->Count()-1; ++i)
1674 pBorders[i].nPos -= _lDiff;
1675 SetBorders(pColumnItem->Count()-1, pBorders);
1676 if(pColumnItem->IsFirstAct())
1678 // Rechten Einzug an alter Position
1679 if(pParaItem)
1681 pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
1682 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1685 else
1687 if(pParaItem)
1689 pIndents[INDENT_FIRST_LINE].nPos -= _lDiff;
1690 pIndents[INDENT_LEFT_MARGIN].nPos -= _lDiff;
1691 pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
1692 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1695 if(pTabStopItem&& (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
1696 &&!IsActFirstColumn())
1698 ModifyTabs_Impl(nTabCount+TAB_GAP, pTabs, -_lDiff);
1699 SetTabs(nTabCount, pTabs+TAB_GAP);
1704 else
1706 long _lDiff = lDragPos - nOld;
1707 SetMargin1(nOld + _lDiff, nMarginStyle );
1709 if(!pColumnItem||!(nDragType & (DRAG_OBJECT_SIZE_LINEAR |
1710 DRAG_OBJECT_SIZE_PROPORTIONAL)))
1712 if(!pColumnItem && !pObjectItem && pParaItem)
1714 // Linke Einzuege an alter Position
1715 pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
1716 pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
1717 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1720 if(pColumnItem)
1722 for(USHORT i = 0; i < pColumnItem->Count()-1; ++i)
1723 pBorders[i].nPos += _lDiff;
1724 SetBorders(pColumnItem->Count()-1, pBorders);
1725 if(pColumnItem->IsFirstAct())
1727 // Linke Einzuege an alter Position
1728 if(pParaItem)
1730 pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
1731 pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
1732 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1735 else
1737 if(pParaItem)
1739 pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
1740 pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
1741 pIndents[INDENT_RIGHT_MARGIN].nPos += _lDiff;
1742 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1746 if(pTabStopItem)
1748 ModifyTabs_Impl(nTabCount+TAB_GAP, pTabs, _lDiff);
1749 SetTabs(nTabCount, pTabs+TAB_GAP);
1756 void SvxRuler::DragMargin2()
1758 [Beschreibung]
1760 Draggen des rechten Frame-Randes
1764 const long lDragPos = GetCorrectedDragPos( TRUE, !TAB_FLAG || !NEG_FLAG);
1765 DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 5 : 7, bHorz);
1766 long lDiff = lDragPos - GetMargin2();
1768 if(pRuler_Imp->bIsTableRows && !bHorz && pColumnItem&&
1769 (//nDragType & DRAG_OBJECT_SIZE_LINEAR ||
1770 nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL))
1771 DragBorders();
1773 BOOL bProtectColumns =
1774 pRuler_Imp->aProtectItem.IsSizeProtected() ||
1775 pRuler_Imp->aProtectItem.IsPosProtected();
1776 const USHORT nMarginStyle =
1777 bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE;
1778 SetMargin2( lDragPos, nMarginStyle );
1780 // Rechten Einzug an alter Position
1781 if((!pColumnItem || IsActLastColumn()) && pParaItem)
1783 pIndents[INDENT_FIRST_LINE].nPos += lDiff;
1784 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1789 void SvxRuler::DragIndents()
1791 [Beschreibung]
1793 Draggen der Absatzeinzuege
1797 const long lDragPos = NEG_FLAG ? GetDragPos() : GetCorrectedDragPos();
1798 const USHORT nIdx = GetDragAryPos()+INDENT_GAP;
1799 const long lDiff = pIndents[nIdx].nPos - lDragPos;
1801 if((nIdx == INDENT_FIRST_LINE ||
1802 nIdx == INDENT_LEFT_MARGIN ) &&
1803 (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
1804 DRAG_OBJECT_LEFT_INDENT_ONLY)
1805 pIndents[INDENT_FIRST_LINE].nPos -= lDiff;
1807 pIndents[nIdx].nPos = lDragPos;
1809 SetIndents(INDENT_COUNT, pIndents + INDENT_GAP);
1810 DrawLine_Impl(lTabPos, 1, bHorz);
1814 void SvxRuler::DrawLine_Impl(long &_lTabPos, int nNew, BOOL Hori)
1816 [Beschreibung]
1818 Ausgaberoutine fuer Hilfslinie beim Vereschieben von Tabs, Tabellen-
1819 und anderen Spalten
1823 if(Hori)
1825 const long nHeight = pEditWin->GetOutputSize().Height();
1826 Point aZero=pEditWin->GetMapMode().GetOrigin();
1827 if(_lTabPos!=-1)
1828 pEditWin->InvertTracking(
1829 Rectangle( Point(_lTabPos, -aZero.Y()),
1830 Point(_lTabPos, -aZero.Y()+nHeight)),
1831 SHOWTRACK_SPLIT | SHOWTRACK_CLIP );
1832 if( nNew & 1 )
1835 _lTabPos = ConvertHSizeLogic(
1836 GetCorrectedDragPos( ( nNew&4 ) != 0, ( nNew&2 ) != 0 ) +
1837 GetNullOffset() );
1838 if(pPagePosItem)
1839 _lTabPos += pPagePosItem->GetPos().X();
1840 pEditWin->InvertTracking(
1841 Rectangle(Point(_lTabPos, -aZero.Y()),
1842 Point(_lTabPos, -aZero.Y()+nHeight)),
1843 SHOWTRACK_CLIP | SHOWTRACK_SPLIT );
1846 else
1848 const long nWidth = pEditWin->GetOutputSize().Width();
1849 Point aZero=pEditWin->GetMapMode().GetOrigin();
1850 if(_lTabPos != -1)
1852 pEditWin->InvertTracking(
1853 Rectangle( Point(-aZero.X(), _lTabPos),
1854 Point(-aZero.X()+nWidth, _lTabPos)),
1855 SHOWTRACK_SPLIT | SHOWTRACK_CLIP );
1858 if(nNew & 1)
1860 _lTabPos = ConvertVSizeLogic(GetCorrectedDragPos()+GetNullOffset());
1861 if(pPagePosItem)
1862 _lTabPos += pPagePosItem->GetPos().Y();
1863 pEditWin->InvertTracking(
1864 Rectangle( Point(-aZero.X(), _lTabPos),
1865 Point(-aZero.X()+nWidth, _lTabPos)),
1866 SHOWTRACK_CLIP | SHOWTRACK_SPLIT );
1874 void SvxRuler::DragTabs()
1877 [Beschreibung]
1879 Draggen von Tabs
1884 long lDragPos = GetCorrectedDragPos(TRUE, FALSE);
1886 USHORT nIdx = GetDragAryPos()+TAB_GAP;
1887 DrawLine_Impl(lTabPos, 7, bHorz);
1889 long nDiff = lDragPos - pTabs[nIdx].nPos;
1891 if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
1894 for(USHORT i = nIdx; i < nTabCount; ++i)
1896 pTabs[i].nPos += nDiff;
1897 // auf Maximum begrenzen
1898 if(pTabs[i].nPos > GetMargin2())
1899 pTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
1900 else
1901 pTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
1904 else if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
1906 pRuler_Imp->nTotalDist -= nDiff;
1907 pTabs[nIdx].nPos = lDragPos;
1908 for(USHORT i = nIdx+1; i < nTabCount; ++i)
1910 if(pTabs[i].nStyle & RULER_TAB_DEFAULT)
1911 // bei den DefaultTabs kann abgebrochen werden
1912 break;
1913 long nDelta = pRuler_Imp->nTotalDist * pRuler_Imp->pPercBuf[i];
1914 nDelta /= 1000;
1915 pTabs[i].nPos = pTabs[nIdx].nPos + nDelta;
1916 if(pTabs[i].nPos+GetNullOffset() > nMaxRight)
1917 pTabs[i].nStyle |= RULER_STYLE_INVISIBLE;
1918 else
1919 pTabs[i].nStyle &= ~RULER_STYLE_INVISIBLE;
1922 else
1923 pTabs[nIdx].nPos = lDragPos;
1925 if(IsDragDelete())
1926 pTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
1927 else
1928 pTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
1929 SetTabs(nTabCount, pTabs+TAB_GAP);
1934 void SvxRuler::SetActive(BOOL bOn)
1936 if(bOn)
1938 Activate();
1939 /* pBindings->Invalidate( SID_RULER_LR_MIN_MAX, TRUE, TRUE );
1940 pBindings->Update( SID_RULER_LR_MIN_MAX );
1941 pBindings->Invalidate( SID_ATTR_LONG_ULSPACE, TRUE, TRUE );
1942 pBindings->Update( SID_ATTR_LONG_ULSPACE );
1943 pBindings->Invalidate( SID_ATTR_LONG_LRSPACE, TRUE, TRUE );
1944 pBindings->Update( SID_ATTR_LONG_LRSPACE );
1945 pBindings->Invalidate( SID_RULER_PAGE_POS, TRUE, TRUE );
1946 pBindings->Update( SID_RULER_PAGE_POS );
1947 pBindings->Invalidate( SID_ATTR_TABSTOP, TRUE, TRUE );
1948 pBindings->Update( SID_ATTR_TABSTOP );
1949 pBindings->Invalidate( SID_ATTR_PARA_LRSPACE, TRUE, TRUE );
1950 pBindings->Update( SID_ATTR_PARA_LRSPACE );
1951 pBindings->Invalidate( SID_RULER_BORDERS, TRUE, TRUE );
1952 pBindings->Update( SID_RULER_BORDERS );
1953 pBindings->Invalidate( SID_RULER_OBJECT, TRUE, TRUE );
1954 pBindings->Update( SID_RULER_OBJECT );
1955 pBindings->Invalidate( SID_RULER_PROTECT, TRUE, TRUE );
1956 pBindings->Update( SID_RULER_PROTECT );*/
1958 else
1959 Deactivate();
1960 if(bActive!=bOn)
1962 pBindings->EnterRegistrations();
1963 if(bOn)
1964 for(USHORT i=0;i<pRuler_Imp->nControlerItems;i++)
1965 pCtrlItem[i]->ReBind();
1966 else
1967 for(USHORT j=0;j<pRuler_Imp->nControlerItems;j++)
1968 pCtrlItem[j]->UnBind();
1969 pBindings->LeaveRegistrations();
1971 bActive = bOn;
1977 void SvxRuler::UpdateParaContents_Impl
1979 long l, // Differenz
1980 UpdateType eType // Art (alle, links oder rechts)
1984 [Beschreibung]
1986 Hilfsroutine; Mitfuehren von Tabulatoren und Absatzraendern
1990 switch(eType) {
1991 case MOVE_RIGHT:
1992 pIndents[INDENT_RIGHT_MARGIN].nPos += l;
1993 break;
1994 case MOVE_ALL:
1995 pIndents[INDENT_RIGHT_MARGIN].nPos += l;
1996 // no break
1997 case MOVE_LEFT:
1999 pIndents[INDENT_FIRST_LINE].nPos += l;
2000 pIndents[INDENT_LEFT_MARGIN].nPos += l;
2001 if ( pTabs )
2003 for(USHORT i = 0; i < nTabCount+TAB_GAP;++i)
2004 pTabs[i].nPos += l;
2005 SetTabs(nTabCount, pTabs+TAB_GAP);
2007 break;
2010 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
2015 void SvxRuler::DragBorders()
2018 [Beschreibung]
2020 Draggen von Borders (Tabellen- und anderen Spalten)
2024 BOOL bLeftIndentsCorrected = FALSE, bRightIndentsCorrected = FALSE;
2025 int nIdx;
2027 if(GetDragType()==RULER_TYPE_BORDER)
2029 DrawLine_Impl(lTabPos, 7, bHorz);
2030 nIdx = GetDragAryPos();
2032 else
2033 nIdx=0;
2035 USHORT nDragSize = GetDragSize();
2036 long lDiff = 0;
2038 // the drag position has to be corrected to be able to prevent borders from passing each other
2039 long lPos = GetCorrectedDragPos();
2042 switch(nDragSize)
2044 case RULER_DRAGSIZE_MOVE:
2046 ADD_DEBUG_TEXT("lLastLMargin: ", String::CreateFromInt32(pRuler_Imp->lLastLMargin))
2047 lDiff = GetDragType()==RULER_TYPE_BORDER ?
2048 lPos-nDragOffset - pBorders[nIdx].nPos
2049 : GetDragType() == RULER_TYPE_MARGIN1 ? lPos - pRuler_Imp->lLastLMargin : lPos - pRuler_Imp->lLastRMargin;
2051 // pBorders[nIdx].nPos += lDiff;
2052 // lDiff = pBorders[nIdx].nPos - nOld;
2053 if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
2055 long nRight = GetMargin2()-lMinFrame; // rechter Begrenzer
2056 for(int i = nBorderCount-2; i >= nIdx; --i)
2058 long l = pBorders[i].nPos;
2059 pBorders[i].nPos += lDiff;
2060 pBorders[i].nPos = Min(pBorders[i].nPos, nRight - pBorders[i].nWidth);
2061 nRight = pBorders[i].nPos - lMinFrame;
2062 // RR der Spalte aktualisieren
2063 if(i == GetActRightColumn())
2065 UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_RIGHT);
2066 bRightIndentsCorrected = TRUE;
2068 // LAR, EZE der Spalte aktualisieren
2069 else if(i == GetActLeftColumn())
2071 UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_LEFT);
2072 bLeftIndentsCorrected = TRUE;
2076 else if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
2078 int nLimit;
2079 long lLeft;
2080 int nStartLimit = nBorderCount-2;
2081 switch(GetDragType())
2083 default: ;//prevent warning
2084 DBG_ERROR("svx::SvxRuler::DragBorders(), unknown drag type!" );
2085 case RULER_TYPE_BORDER:
2086 if(pRuler_Imp->bIsTableRows)
2088 pBorders[nIdx].nPos += lDiff;
2089 if(bHorz)
2091 lLeft = pBorders[nIdx].nPos;
2092 pRuler_Imp->nTotalDist -= lDiff;
2093 nLimit=nIdx+1;
2095 else
2097 lLeft = 0;
2098 nStartLimit = nIdx - 1;
2099 pRuler_Imp->nTotalDist += lDiff;
2100 nLimit = 0;
2103 else
2105 nLimit=nIdx+1;
2106 pBorders[nIdx].nPos += lDiff;
2107 lLeft = pBorders[nIdx].nPos;
2108 pRuler_Imp->nTotalDist-=lDiff;
2110 break;
2111 case RULER_TYPE_MARGIN1:
2112 nLimit=0;
2113 lLeft=pRuler_Imp->lLastLMargin+lDiff;
2114 pRuler_Imp->nTotalDist-=lDiff;
2115 break;
2116 case RULER_TYPE_MARGIN2:
2117 nLimit = 0;
2118 lLeft= 0;//pRuler_Imp->lLastRMargin + lDiff;
2119 nStartLimit = nBorderCount - 2;
2120 pRuler_Imp->nTotalDist += lDiff;
2121 break;
2124 for(int i = nStartLimit; i >= nLimit; --i)
2127 long l = pBorders[i].nPos;
2128 pBorders[i].nPos=lLeft+
2129 (pRuler_Imp->nTotalDist*pRuler_Imp->pPercBuf[i])/1000+
2130 pRuler_Imp->pBlockBuf[i];
2132 // RR der Spalte aktualisieren
2133 if(!pRuler_Imp->bIsTableRows)
2135 if(i == GetActRightColumn())
2137 UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_RIGHT);
2138 bRightIndentsCorrected = TRUE;
2140 // LAR, EZE der Spalte aktualisieren
2141 else if(i == GetActLeftColumn())
2143 UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_LEFT);
2144 bLeftIndentsCorrected = TRUE;
2148 if(pRuler_Imp->bIsTableRows)
2150 //in vertical tables the left borders have to be moved
2151 if(bHorz)
2153 for(int i = 0; i < nIdx; ++i)
2154 pBorders[i].nPos += lDiff;
2155 AdjustMargin1(lDiff);
2157 else
2159 //otherwise the right borders are moved
2160 for(int i = pColumnItem->Count() - 1; i > nIdx; --i)
2161 pBorders[i].nPos += lDiff;
2162 SetMargin2( GetMargin2() + lDiff, 0 );
2166 else if(pRuler_Imp->bIsTableRows)
2168 //moving rows: if a row is resized all following rows
2169 //have to be moved by the same amount.
2170 //This includes the left border when the table is not limited
2171 //to a lower frame border.
2172 int nLimit;
2173 long lLeft;
2174 if(GetDragType()==RULER_TYPE_BORDER)
2176 nLimit=nIdx+1;
2177 lLeft=(pBorders[nIdx].nPos+=lDiff);
2179 else
2181 nLimit=0;
2182 lLeft=pRuler_Imp->lLastLMargin+lDiff;
2184 //in vertical tables the left borders have to be moved
2185 if(bHorz)
2187 for(int i = 0; i < nIdx; ++i)
2189 pBorders[i].nPos += lDiff;
2191 AdjustMargin1(lDiff);
2193 else
2195 //otherwise the right borders are moved
2196 for(int i = nBorderCount-2; i >= nLimit; --i)
2198 pBorders[i].nPos += lDiff;
2200 SetMargin2( GetMargin2() + lDiff, 0 );
2203 else
2204 pBorders[nIdx].nPos+=lDiff;
2205 break;
2207 case RULER_DRAGSIZE_1:
2209 lDiff = lPos - pBorders[nIdx].nPos;
2210 pBorders[nIdx].nWidth += pBorders[nIdx].nPos - lPos;
2211 pBorders[nIdx].nPos = lPos;
2212 break;
2214 case RULER_DRAGSIZE_2:
2216 const long nOld = pBorders[nIdx].nWidth;
2217 pBorders[nIdx].nWidth = lPos - pBorders[nIdx].nPos;
2218 lDiff = pBorders[nIdx].nWidth - nOld;
2219 break;
2222 if(!bRightIndentsCorrected &&
2223 GetActRightColumn() == nIdx &&
2224 nDragSize != RULER_DRAGSIZE_2 && pIndents &&
2225 !pRuler_Imp->bIsTableRows)
2227 UpdateParaContents_Impl(lDiff, MOVE_RIGHT);
2229 else if(!bLeftIndentsCorrected &&
2230 GetActLeftColumn()==nIdx &&
2231 nDragSize != RULER_DRAGSIZE_1 && pIndents)
2233 UpdateParaContents_Impl(lDiff, MOVE_LEFT);
2235 SetBorders(pColumnItem->Count()-1, pBorders);
2239 void SvxRuler::DragObjectBorder()
2242 [Beschreibung]
2244 Draggen von Objektraendern
2248 if(RULER_DRAGSIZE_MOVE == GetDragSize())
2250 const long lPos = GetCorrectedDragPos();
2251 const USHORT nIdx = GetDragAryPos();
2252 pObjectBorders[GetObjectBordersOff(nIdx)].nPos = lPos;
2253 SetBorders(2, pObjectBorders + GetObjectBordersOff(0));
2254 DrawLine_Impl(lTabPos, 7, bHorz);
2260 void SvxRuler::ApplyMargins()
2262 [Beschreibung]
2264 Anwenden von Randeinstellungen; durch Draggen veraendert.
2268 const SfxPoolItem *pItem = 0;
2269 USHORT nId = SID_ATTR_LONG_LRSPACE;
2270 if(bHorz)
2272 const long lOldNull = lLogicNullOffset;
2273 if(pRuler_Imp->lMaxLeftLogic!=-1&&nMaxLeft==GetMargin1()+Ruler::GetNullOffset())
2274 pLRSpaceItem->SetLeft(lLogicNullOffset=pRuler_Imp->lMaxLeftLogic);
2275 else
2276 pLRSpaceItem->SetLeft(PixelHAdjust(
2277 lLogicNullOffset = ConvertHPosLogic(GetFrameLeft()) -
2278 lAppNullOffset, pLRSpaceItem->GetLeft()));
2280 if(bAppSetNullOffset)
2281 lAppNullOffset += lLogicNullOffset - lOldNull;
2283 if(pRuler_Imp->lMaxRightLogic!=-1
2284 &&nMaxRight==GetMargin2()+Ruler::GetNullOffset())
2285 pLRSpaceItem->SetRight(GetPageWidth()-pRuler_Imp->lMaxRightLogic);
2286 else
2287 pLRSpaceItem->SetRight(
2288 PixelHAdjust(
2289 Max((long)0,pPagePosItem->GetWidth() -
2290 pLRSpaceItem->GetLeft() -
2291 (ConvertHPosLogic(GetMargin2()) -
2292 lAppNullOffset)),pLRSpaceItem->GetRight()));
2293 pItem = pLRSpaceItem;
2294 #ifdef DEBUGLIN
2295 Debug_Impl(pEditWin,*pLRSpaceItem);
2296 #endif // DEBUGLIN
2298 else {
2299 const long lOldNull = lLogicNullOffset;
2300 pULSpaceItem->SetUpper(
2301 PixelVAdjust(
2302 lLogicNullOffset =
2303 ConvertVPosLogic(GetFrameLeft()) -
2304 lAppNullOffset,pULSpaceItem->GetUpper()));
2305 if(bAppSetNullOffset)
2306 lAppNullOffset += lLogicNullOffset - lOldNull;
2307 pULSpaceItem->SetLower(
2308 PixelVAdjust(
2309 Max((long)0, pPagePosItem->GetHeight() -
2310 pULSpaceItem->GetUpper() -
2311 (ConvertVPosLogic(GetMargin2()) -
2312 lAppNullOffset)),pULSpaceItem->GetLower()));
2313 pItem = pULSpaceItem;
2314 nId = SID_ATTR_LONG_ULSPACE;
2315 #ifdef DEBUGLIN
2316 Debug_Impl(pEditWin,*pULSpaceItem);
2317 #endif // DEBUGLIN
2319 pBindings->GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, pItem, 0L );
2320 if(pTabStopItem)
2321 UpdateTabs();
2325 void SvxRuler::ApplyIndents()
2327 [Beschreibung]
2329 Anwenden von Absatzeinstellungen; durch Draggen veraendert.
2333 long nNewTxtLeft;
2334 if(pColumnItem&&!IsActFirstColumn( TRUE ))
2336 long nLeftCol=GetActLeftColumn( TRUE );
2337 nNewTxtLeft =
2338 PixelHAdjust(
2339 ConvertHPosLogic(
2340 pIndents[INDENT_LEFT_MARGIN].nPos-
2341 (pBorders[nLeftCol].nPos +
2342 pBorders[nLeftCol].nWidth))-
2343 lAppNullOffset,pParaItem->GetTxtLeft());
2345 else
2346 nNewTxtLeft =
2347 PixelHAdjust(
2348 ConvertHPosLogic(pIndents[INDENT_LEFT_MARGIN].nPos),
2349 pParaItem->GetTxtLeft());
2351 BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
2353 long nNewFirstLineOffset;
2354 if(bRTL)
2356 long nRightFrameMargin = GetRightFrameMargin();
2357 nNewFirstLineOffset = PixelHAdjust(nRightFrameMargin -
2358 ConvertHPosLogic(pIndents[INDENT_FIRST_LINE].nPos ) -
2359 lAppNullOffset,
2360 pParaItem->GetTxtFirstLineOfst());
2362 else
2363 nNewFirstLineOffset=
2364 PixelHAdjust(
2365 ConvertHPosLogic(pIndents[INDENT_FIRST_LINE].nPos -
2366 pIndents[INDENT_LEFT_MARGIN].nPos) -
2367 lAppNullOffset,
2368 pParaItem->GetTxtFirstLineOfst());
2370 // #62986# : Ist der neue TxtLeft kleiner als der alte FirstLineIndent,
2371 // dann geht die Differenz verloren und der Absatz wird insgesamt
2372 // zu weit eingerueckt, deswegen erst den FirstLineOffset setzen, dann den TxtLeft
2373 if(bRTL)
2375 long nLeftFrameMargin = GetLeftFrameMargin();
2376 long nRightFrameMargin = GetRightFrameMargin();
2377 nNewTxtLeft = nRightFrameMargin - nNewTxtLeft - nLeftFrameMargin;
2378 nNewFirstLineOffset -= nNewTxtLeft;
2379 if(pParaBorderItem)
2381 nNewTxtLeft += pParaBorderItem->GetLeft() + pParaBorderItem->GetRight();
2382 nNewFirstLineOffset -= pParaBorderItem->GetRight();
2385 pParaItem->SetTxtFirstLineOfst(
2386 sal::static_int_cast< short >(nNewFirstLineOffset));
2387 pParaItem->SetTxtLeft(nNewTxtLeft);
2389 if(pColumnItem && ((!bRTL && !IsActLastColumn( TRUE ))|| (bRTL && !IsActFirstColumn())))
2391 if(bRTL)
2393 long nActBorder = pBorders[GetActLeftColumn( TRUE )].nPos;
2394 long nRightMargin = pIndents[INDENT_RIGHT_MARGIN].nPos;
2395 long nConvert = ConvertHPosLogic( nRightMargin - nActBorder );
2396 pParaItem->SetRight( PixelHAdjust( nConvert - lAppNullOffset, pParaItem->GetRight() ) );
2398 else
2400 pParaItem->SetRight(
2401 PixelHAdjust(
2402 ConvertHPosLogic(
2403 pBorders[GetActRightColumn( TRUE )].nPos -
2404 pIndents[INDENT_RIGHT_MARGIN].nPos) -
2405 lAppNullOffset,
2406 pParaItem->GetRight()));
2410 else
2412 if(bRTL)
2414 pParaItem->SetRight( PixelHAdjust(
2415 ConvertHPosLogic(GetMargin1() +
2416 pIndents[INDENT_RIGHT_MARGIN].nPos) - GetLeftFrameMargin() +
2417 (pParaBorderItem ? pParaBorderItem->GetLeft() : 0) -
2418 lAppNullOffset, pParaItem->GetRight()));
2420 else
2422 pParaItem->SetRight( PixelHAdjust(
2423 ConvertHPosLogic(GetMargin2() -
2424 pIndents[INDENT_RIGHT_MARGIN].nPos) -
2425 lAppNullOffset, pParaItem->GetRight()));
2428 USHORT nParaId = bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL;
2429 pBindings->GetDispatcher()->Execute( nParaId, SFX_CALLMODE_RECORD, pParaItem, 0L );
2430 UpdateTabs();
2434 void SvxRuler::ApplyTabs()
2436 [Beschreibung]
2438 Anwenden von Tabulatoreinstellungen; durch Draggen veraendert.
2442 BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
2443 const USHORT nCoreIdx = GetDragAryPos();
2444 if(IsDragDelete())
2446 pTabStopItem->Remove(nCoreIdx);
2448 else if(DRAG_OBJECT_SIZE_LINEAR & nDragType ||
2449 DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType)
2451 SvxTabStopItem *pItem = new SvxTabStopItem(pTabStopItem->Which());
2452 //remove default tab stops
2453 for ( USHORT i = 0; i < pItem->Count(); )
2455 if ( SVX_TAB_ADJUST_DEFAULT == (*pItem)[i].GetAdjustment() )
2457 pItem->Remove(i);
2458 continue;
2460 ++i;
2463 USHORT j;
2464 for(j = 0; j < nCoreIdx; ++j)
2466 pItem->Insert((*pTabStopItem)[j]);
2468 for(; j < pTabStopItem->Count(); ++j)
2470 SvxTabStop aTabStop = (*pTabStopItem)[j];
2471 aTabStop.GetTabPos() = PixelHAdjust(
2472 ConvertHPosLogic(pTabs[j+TAB_GAP].nPos -
2473 GetLeftIndent()) -
2474 lAppNullOffset,
2475 aTabStop.GetTabPos());
2476 pItem->Insert(aTabStop);
2478 delete pTabStopItem;
2479 pTabStopItem = pItem;
2481 else if( pTabStopItem->Count() == 0 )
2482 return;
2483 else
2485 SvxTabStop aTabStop = (*pTabStopItem)[nCoreIdx];
2486 if(pRuler_Imp->lMaxRightLogic!=-1&&
2487 pTabs[nCoreIdx+TAB_GAP].nPos+Ruler::GetNullOffset()==nMaxRight)
2488 aTabStop.GetTabPos() = pRuler_Imp->lMaxRightLogic-lLogicNullOffset;
2489 else
2491 if(bRTL)
2493 //#i24363# tab stops relative to indent
2494 const long nTmpLeftIndent = pRuler_Imp->bIsTabsRelativeToIndent ?
2495 GetLeftIndent() :
2496 ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset );
2498 aTabStop.GetTabPos() = PixelHAdjust(
2499 ConvertHPosLogic( nTmpLeftIndent - pTabs[nCoreIdx+TAB_GAP].nPos) - lAppNullOffset,
2500 aTabStop.GetTabPos());
2502 else
2504 //#i24363# tab stops relative to indent
2505 const long nTmpLeftIndent = pRuler_Imp->bIsTabsRelativeToIndent ?
2506 GetLeftIndent() :
2509 aTabStop.GetTabPos() = PixelHAdjust(
2510 ConvertHPosLogic( pTabs[nCoreIdx+TAB_GAP].nPos - nTmpLeftIndent ) - lAppNullOffset,
2511 aTabStop.GetTabPos() );
2514 pTabStopItem->Remove(nCoreIdx);
2515 pTabStopItem->Insert(aTabStop);
2517 USHORT nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
2518 pBindings->GetDispatcher()->Execute( nTabStopId, SFX_CALLMODE_RECORD, pTabStopItem, 0L );
2519 UpdateTabs();
2523 void SvxRuler::ApplyBorders()
2525 [Beschreibung]
2527 Anwenden von (Tabellen-)Spalteneinstellungen; durch Draggen veraendert.
2531 if(pColumnItem->IsTable())
2533 long l = GetFrameLeft();
2534 if(l != pRuler_Imp->nColLeftPix)
2535 pColumnItem->SetLeft( PixelHAdjust(
2536 ConvertHPosLogic(l) - lAppNullOffset, pColumnItem->GetLeft()));
2537 l = GetMargin2();
2538 if(l != pRuler_Imp->nColRightPix)
2540 long nWidthOrHeight = bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
2541 pColumnItem->SetRight( PixelHAdjust( nWidthOrHeight -
2542 pColumnItem->GetLeft() - ConvertHPosLogic(l) -
2543 lAppNullOffset, pColumnItem->GetRight() ) );
2546 for(USHORT i = 0; i < pColumnItem->Count()-1; ++i)
2548 long& nEnd = (*pColumnItem)[i].nEnd;
2549 nEnd = PIXEL_H_ADJUST(
2550 ConvertPosLogic(pBorders[i].nPos),
2551 (*pColumnItem)[i].nEnd);
2552 long& nStart = (*pColumnItem)[i+1].nStart;
2553 nStart = PIXEL_H_ADJUST(
2554 ConvertSizeLogic(pBorders[i].nPos +
2555 pBorders[i].nWidth) -
2556 lAppNullOffset,
2557 (*pColumnItem)[i+1].nStart);
2558 // Es kann sein, dass aufgrund der PIXEL_H_ADJUST rejustierung auf
2559 // alte Werte die Breite < 0 wird. Das rerejustieren wir.
2560 if( nEnd > nStart )
2561 nStart = nEnd;
2563 #ifdef DEBUGLIN
2564 Debug_Impl(pEditWin,*pColumnItem);
2565 #endif // DEBUGLIN
2566 SfxBoolItem aFlag(SID_RULER_ACT_LINE_ONLY,
2567 nDragType & DRAG_OBJECT_ACTLINE_ONLY? TRUE: FALSE);
2568 USHORT nColId = pRuler_Imp->bIsTableRows ? (bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL) :
2569 (bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
2570 pBindings->GetDispatcher()->Execute( nColId, SFX_CALLMODE_RECORD, pColumnItem, &aFlag, 0L );
2573 void SvxRuler::ApplyObject()
2575 [Beschreibung]
2577 Anwenden von Objekteinstellungen; durch Draggen veraendert.
2581 // zum Seitenrand
2582 long nMargin = pLRSpaceItem? pLRSpaceItem->GetLeft(): 0;
2583 pObjectItem->SetStartX(
2584 PixelAdjust(
2585 ConvertPosLogic(pObjectBorders[0].nPos)
2586 + nMargin - lAppNullOffset,pObjectItem->GetStartX()));
2587 pObjectItem->SetEndX(
2588 PixelAdjust(
2589 ConvertPosLogic(pObjectBorders[1].nPos)
2590 + nMargin - lAppNullOffset,pObjectItem->GetEndX()));
2591 nMargin = pULSpaceItem? pULSpaceItem->GetUpper(): 0;
2592 pObjectItem->SetStartY(
2593 PixelAdjust(
2594 ConvertPosLogic(pObjectBorders[2].nPos)
2595 + nMargin - lAppNullOffset,pObjectItem->GetStartY()));
2596 pObjectItem->SetEndY(
2597 PixelAdjust(
2598 ConvertPosLogic(pObjectBorders[3].nPos)
2599 + nMargin - lAppNullOffset,pObjectItem->GetEndY()));
2600 pBindings->GetDispatcher()->Execute( SID_RULER_OBJECT, SFX_CALLMODE_RECORD, pObjectItem, 0L );
2603 void SvxRuler::PrepareProportional_Impl(RulerType eType)
2605 [Beschreibung]
2607 Vorbereitung proportionales Draggen; es wird der proportionale
2608 Anteil bezogen auf die Gesamtbreite in Promille berechnet.
2612 pRuler_Imp->nTotalDist = GetMargin2();
2613 switch((int)eType)
2615 case RULER_TYPE_MARGIN2:
2616 case RULER_TYPE_MARGIN1:
2617 case RULER_TYPE_BORDER:
2619 DBG_ASSERT(pColumnItem, "kein ColumnItem");
2621 pRuler_Imp->SetPercSize(pColumnItem->Count());
2623 long lPos;
2624 long lWidth=0;
2625 USHORT nStart;
2626 USHORT nIdx=GetDragAryPos();
2627 lWidth=0;
2628 long lActWidth=0;
2629 long lActBorderSum;
2630 long lOrigLPos;
2632 if(eType != RULER_TYPE_BORDER)
2634 lOrigLPos = GetMargin1();
2635 nStart = 0;
2636 lActBorderSum = 0;
2638 else
2640 if(pRuler_Imp->bIsTableRows &&!bHorz)
2642 lOrigLPos = GetMargin1();
2643 nStart = 0;
2645 else
2647 lOrigLPos = pBorders[nIdx].nPos + pBorders[nIdx].nWidth;
2648 nStart = 1;
2650 lActBorderSum = pBorders[nIdx].nWidth;
2653 //in horizontal mode the percentage value has to be
2654 //calculated on a "current change" position base
2655 //because the height of the table changes while dragging
2656 if(pRuler_Imp->bIsTableRows && RULER_TYPE_BORDER == eType)
2658 USHORT nStartBorder;
2659 USHORT nEndBorder;
2660 if(bHorz)
2662 nStartBorder = nIdx + 1;
2663 nEndBorder = pColumnItem->Count() - 1;
2665 else
2667 nStartBorder = 0;
2668 nEndBorder = nIdx;
2671 lWidth = pBorders[nIdx].nPos;
2672 if(bHorz)
2673 lWidth = GetMargin2() - lWidth;
2674 pRuler_Imp->nTotalDist = lWidth;
2675 lPos = lOrigLPos = pBorders[nIdx].nPos;
2677 for(USHORT i = nStartBorder; i < nEndBorder; ++i)
2679 if(bHorz)
2681 lActWidth += pBorders[i].nPos - lPos;
2682 lPos = pBorders[i].nPos + pBorders[i].nWidth;
2684 else
2685 lActWidth = pBorders[i].nPos;
2686 pRuler_Imp->pPercBuf[i] = (USHORT)((lActWidth * 1000)
2687 / pRuler_Imp->nTotalDist);
2688 pRuler_Imp->pBlockBuf[i] = (USHORT)lActBorderSum;
2689 lActBorderSum += pBorders[i].nWidth;
2692 else
2694 lPos = lOrigLPos;
2695 for(USHORT ii = nStart; ii < pColumnItem->Count() - 1; ++ii)
2697 lWidth += pBorders[ii].nPos - lPos;
2698 lPos = pBorders[ii].nPos + pBorders[ii].nWidth;
2701 lWidth += GetMargin2() - lPos;
2702 pRuler_Imp->nTotalDist = lWidth;
2703 lPos = lOrigLPos;
2705 for(USHORT i = nStart; i < pColumnItem->Count() - 1; ++i)
2707 lActWidth += pBorders[i].nPos - lPos;
2708 lPos = pBorders[i].nPos + pBorders[i].nWidth;
2709 pRuler_Imp->pPercBuf[i] = (USHORT)((lActWidth * 1000)
2710 / pRuler_Imp->nTotalDist);
2711 pRuler_Imp->pBlockBuf[i] = (USHORT)lActBorderSum;
2712 lActBorderSum += pBorders[i].nWidth;
2716 break;
2717 case RULER_TYPE_TAB:
2719 const USHORT nIdx = GetDragAryPos()+TAB_GAP;
2720 pRuler_Imp->nTotalDist -= pTabs[nIdx].nPos;
2721 pRuler_Imp->SetPercSize(nTabCount);
2722 for(USHORT n=0;n<=nIdx;pRuler_Imp->pPercBuf[n++]=0) ;
2723 for(USHORT i = nIdx+1; i < nTabCount; ++i)
2725 const long nDelta = pTabs[i].nPos - pTabs[nIdx].nPos;
2726 pRuler_Imp->pPercBuf[i] = (USHORT)((nDelta * 1000) / pRuler_Imp->nTotalDist);
2728 break;
2734 void SvxRuler::EvalModifier()
2737 [Beschreibung]
2739 Modifier Draggen auswerten
2741 Shift: Linear verschieben
2742 Control: Proportional verschieben
2743 Shift+Control: Tabelle: nur aktuelle Zeile
2744 alt: Bemassungspfeile (n.i.) //!!
2749 USHORT nModifier = GetDragModifier();
2750 if(pRuler_Imp->bIsTableRows)
2752 //rows can only be moved in one way, additionally current column is possible
2753 if(nModifier == KEY_SHIFT)
2754 nModifier = 0;
2756 switch(nModifier)
2758 case KEY_SHIFT:
2759 nDragType = DRAG_OBJECT_SIZE_LINEAR;
2760 break;
2761 case KEY_MOD1: {
2762 const RulerType eType = GetDragType();
2763 nDragType = DRAG_OBJECT_SIZE_PROPORTIONAL;
2764 if(RULER_TYPE_BORDER == eType || RULER_TYPE_TAB == eType||
2765 RULER_TYPE_MARGIN1&&pColumnItem)
2766 PrepareProportional_Impl(eType);
2767 break;
2769 case KEY_MOD1 | KEY_SHIFT:
2770 if(GetDragType()!=RULER_TYPE_MARGIN1&&
2771 GetDragType()!=RULER_TYPE_MARGIN2)
2772 nDragType = DRAG_OBJECT_ACTLINE_ONLY;
2773 break;
2774 // alt: Bemassungspfeile
2779 void __EXPORT SvxRuler::Click()
2782 [Beschreibung]
2784 Ueberladener Handler SV; setzt Tab per Dispatcheraufruf
2789 Ruler::Click();
2790 if( bActive )
2792 pBindings->Update( SID_RULER_LR_MIN_MAX );
2793 pBindings->Update( SID_ATTR_LONG_ULSPACE );
2794 pBindings->Update( SID_ATTR_LONG_LRSPACE );
2795 pBindings->Update( SID_RULER_PAGE_POS );
2796 pBindings->Update( bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL);
2797 pBindings->Update( bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL);
2798 pBindings->Update( bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
2799 pBindings->Update( bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL);
2800 pBindings->Update( SID_RULER_OBJECT );
2801 pBindings->Update( SID_RULER_PROTECT );
2802 pBindings->Update( SID_ATTR_PARA_LRSPACE_VERTICAL );
2804 BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
2805 if(pTabStopItem &&
2806 (nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS)
2808 BOOL bContentProtected = pRuler_Imp->aProtectItem.IsCntntProtected();
2809 if( bContentProtected ) return;
2810 const long lPos = GetClickPos();
2811 if((bRTL && lPos < Min(GetFirstLineIndent(), GetLeftIndent()) && lPos > GetRightIndent()) ||
2812 (!bRTL && lPos > Min(GetFirstLineIndent(), GetLeftIndent()) && lPos < GetRightIndent()))
2814 //convert position in left-to-right text
2815 long nTabPos;
2816 //#i24363# tab stops relative to indent
2817 if(bRTL)
2818 nTabPos = ( pRuler_Imp->bIsTabsRelativeToIndent ?
2819 GetLeftIndent() :
2820 ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset ) ) -
2821 lPos;
2822 else
2823 nTabPos = lPos -
2824 ( pRuler_Imp->bIsTabsRelativeToIndent ?
2825 GetLeftIndent() :
2826 0 );
2828 SvxTabStop aTabStop(ConvertHPosLogic(nTabPos),
2829 ToAttrTab_Impl(nDefTabType));
2830 pTabStopItem->Insert(aTabStop);
2831 UpdateTabs();
2837 BOOL SvxRuler::CalcLimits
2839 long &nMax1, // zu setzenden Minimalwert
2840 long &nMax2, // zu setzenden Maximalwert
2841 BOOL
2842 ) const
2844 [Beschreibung]
2846 Defaultimplementierung der virtuellen Funktion; kann die Applikation
2847 ueberladen, um eine eigene Grenzwertbehandlung zu implementieren.
2848 Die Werte sind auf die Seite bezogen.
2851 nMax1 = LONG_MIN;
2852 nMax2 = LONG_MAX;
2853 return FALSE;
2857 void SvxRuler::CalcMinMax()
2860 [Beschreibung]
2862 Berechnet die Grenzwerte fuers Draggen; diese sind in Pixeln
2863 relativ zum Seitenrand
2868 BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
2869 const long lNullPix = ConvertPosPixel(lLogicNullOffset);
2870 pRuler_Imp->lMaxLeftLogic=pRuler_Imp->lMaxRightLogic=-1;
2871 switch(GetDragType())
2873 case RULER_TYPE_MARGIN1:
2874 { // linker Rand umgebender Frame
2875 // DragPos - NOf zwischen links - rechts
2876 pRuler_Imp->lMaxLeftLogic = GetLeftMin();
2877 nMaxLeft=ConvertSizePixel(pRuler_Imp->lMaxLeftLogic);
2879 if(!pColumnItem || pColumnItem->Count() == 1 )
2881 if(bRTL)
2883 nMaxRight = lNullPix - GetRightIndent() +
2884 Max(GetFirstLineIndent(), GetLeftIndent()) -
2885 lMinFrame;
2887 else
2889 nMaxRight = lNullPix + GetRightIndent() -
2890 Max(GetFirstLineIndent(), GetLeftIndent()) -
2891 lMinFrame;
2894 else if(pRuler_Imp->bIsTableRows)
2896 //top border is not moveable when table rows are displayed
2897 // protection of content means the margin is not moveable - it's just a page break inside of a cell
2898 if(bHorz && !pRuler_Imp->aProtectItem.IsCntntProtected())
2900 nMaxLeft = pBorders[0].nMinPos + lNullPix;
2901 if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
2902 nMaxRight = GetRightIndent() + lNullPix -
2903 (pColumnItem->Count() - 1 ) * lMinFrame;
2904 else
2905 nMaxRight = pBorders[0].nPos - lMinFrame + lNullPix;
2907 else
2908 nMaxLeft = nMaxRight = lNullPix;
2910 else
2912 if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
2913 //nDragType & DRAG_OBJECT_SIZE_LINEAR)
2915 nMaxRight=lNullPix+CalcPropMaxRight();
2917 else if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
2919 nMaxRight = ConvertPosPixel(
2920 GetPageWidth() - (
2921 (pColumnItem->IsTable() && pLRSpaceItem)
2922 ? pLRSpaceItem->GetRight() : 0))
2923 - GetMargin2() + GetMargin1();
2925 else
2927 nMaxRight = lNullPix - lMinFrame;
2928 if(pColumnItem->IsFirstAct())
2930 if(bRTL)
2932 nMaxRight += Min(
2933 pBorders[0].nPos,
2934 Max(GetFirstLineIndent(), GetLeftIndent()) - GetRightIndent());
2936 else
2938 nMaxRight += Min(
2939 pBorders[0].nPos, GetRightIndent() -
2940 Max(GetFirstLineIndent(), GetLeftIndent()));
2943 else if( pColumnItem->Count() > 1 )
2944 nMaxRight += pBorders[0].nPos;
2945 else
2946 nMaxRight +=GetRightIndent() -
2947 Max(GetFirstLineIndent(), GetLeftIndent());
2948 // den linken Tabellen-Rand nicht ueber den Seitenrand ziehen
2949 if(pLRSpaceItem&&pColumnItem->IsTable())
2951 long nTmp=ConvertSizePixel(pLRSpaceItem->GetLeft());
2952 if(nTmp>nMaxLeft)
2953 nMaxLeft=nTmp;
2957 break;
2959 case RULER_TYPE_MARGIN2:
2960 { // rechter Rand umgebender Frame
2961 pRuler_Imp->lMaxRightLogic =
2962 pMinMaxItem ?
2963 GetPageWidth() - GetRightMax() : GetPageWidth();
2964 nMaxRight = ConvertSizePixel(pRuler_Imp->lMaxRightLogic);
2967 if(!pColumnItem)
2969 if(bRTL)
2971 nMaxLeft = GetMargin2() + GetRightIndent() -
2972 Max(GetFirstLineIndent(),GetLeftIndent()) - GetMargin1()+
2973 lMinFrame + lNullPix;
2975 else
2977 nMaxLeft = GetMargin2() - GetRightIndent() +
2978 Max(GetFirstLineIndent(),GetLeftIndent()) - GetMargin1()+
2979 lMinFrame + lNullPix;
2982 else if(pRuler_Imp->bIsTableRows)
2984 // get the bottom move range from the last border position - only available for rows!
2985 // protection of content means the margin is not moveable - it's just a page break inside of a cell
2986 if(bHorz || pRuler_Imp->aProtectItem.IsCntntProtected())
2988 nMaxLeft = nMaxRight = pBorders[pColumnItem->Count() - 1].nMaxPos + lNullPix;
2990 else
2992 if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
2994 nMaxLeft = (pColumnItem->Count()) * lMinFrame + lNullPix;
2996 else
2998 if(pColumnItem->Count() > 1)
2999 nMaxLeft = pBorders[pColumnItem->Count() - 2].nPos + lMinFrame + lNullPix;
3000 else
3001 nMaxLeft = lMinFrame + lNullPix;
3003 if(pColumnItem->Count() > 1)
3004 nMaxRight = pBorders[pColumnItem->Count() - 2].nMaxPos + lNullPix;
3005 else
3006 nMaxRight -= GetRightIndent() - lNullPix;
3009 else
3011 nMaxLeft = lMinFrame + lNullPix;
3012 if(IsActLastColumn() || pColumnItem->Count() < 2 ) //Falls letzte Spalte aktiv
3014 if(bRTL)
3016 nMaxLeft = lMinFrame + lNullPix + GetMargin2() +
3017 GetRightIndent() - Max(GetFirstLineIndent(),
3018 GetLeftIndent());
3020 else
3022 nMaxLeft = lMinFrame + lNullPix + GetMargin2() -
3023 GetRightIndent() + Max(GetFirstLineIndent(),
3024 GetLeftIndent());
3027 if( pColumnItem->Count() >= 2 )
3029 long nNewMaxLeft =
3030 lMinFrame + lNullPix +
3031 pBorders[pColumnItem->Count()-2].nPos +
3032 pBorders[pColumnItem->Count()-2].nWidth;
3033 nMaxLeft=Max(nMaxLeft,nNewMaxLeft);
3037 break;
3039 case RULER_TYPE_BORDER:
3040 { // Tabelle, Spalten (Modifier)
3041 const USHORT nIdx = GetDragAryPos();
3042 switch(GetDragSize())
3044 case RULER_DRAGSIZE_1 :
3046 nMaxRight = pBorders[nIdx].nPos +
3047 pBorders[nIdx].nWidth + lNullPix;
3049 if(0 == nIdx)
3050 nMaxLeft = lNullPix;
3051 else
3052 nMaxLeft = pBorders[nIdx-1].nPos +
3053 pBorders[nIdx-1].nWidth + lNullPix;
3054 if(nIdx == pColumnItem->GetActColumn())
3056 if(bRTL)
3058 nMaxLeft += pBorders[nIdx].nPos +
3059 GetRightIndent() - Max(GetFirstLineIndent(),
3060 GetLeftIndent());
3062 else
3064 nMaxLeft += pBorders[nIdx].nPos -
3065 GetRightIndent() + Max(GetFirstLineIndent(),
3066 GetLeftIndent());
3068 if(0 != nIdx)
3069 nMaxLeft -= pBorders[nIdx-1].nPos +
3070 pBorders[nIdx-1].nWidth;
3072 nMaxLeft += lMinFrame;
3073 nMaxLeft += nDragOffset;
3074 break;
3076 case RULER_DRAGSIZE_MOVE:
3078 if(pColumnItem)
3080 //nIdx contains the position of the currently moved item
3081 //next visible separator on the left
3082 USHORT nLeftCol=GetActLeftColumn(FALSE, nIdx);
3083 //next visible separator on the right
3084 USHORT nRightCol=GetActRightColumn(FALSE, nIdx);
3085 //next separator on the left - regardless if visible or not
3086 USHORT nActLeftCol=GetActLeftColumn();
3087 //next separator on the right - regardless if visible or not
3088 USHORT nActRightCol=GetActRightColumn();
3089 if(pColumnItem->IsTable())
3091 if(nDragType & DRAG_OBJECT_ACTLINE_ONLY)
3093 //the current row/column should be modified only
3094 //then the next/previous visible border position
3095 //marks the min/max positions
3096 nMaxLeft = nLeftCol == USHRT_MAX ?
3098 pBorders[nLeftCol].nPos;
3099 //rows can always be increased without a limit
3100 if(pRuler_Imp->bIsTableRows)
3101 nMaxRight = pBorders[nIdx].nMaxPos;
3102 else
3103 nMaxRight = nRightCol == USHRT_MAX ?
3104 GetMargin2():
3105 pBorders[nRightCol].nPos;
3106 nMaxLeft += lNullPix;
3107 nMaxRight += lNullPix;
3109 else
3111 if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType && !bHorz && pRuler_Imp->bIsTableRows)
3112 nMaxLeft = (nIdx + 1) * lMinFrame + lNullPix;
3113 else
3114 nMaxLeft = pBorders[nIdx].nMinPos + lNullPix;
3115 if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType||
3116 (DRAG_OBJECT_SIZE_LINEAR & nDragType) )
3118 if(pRuler_Imp->bIsTableRows)
3120 if(bHorz)
3121 nMaxRight = GetRightIndent() + lNullPix -
3122 (pColumnItem->Count() - nIdx - 1) * lMinFrame;
3123 else
3124 nMaxRight = pBorders[nIdx].nMaxPos + lNullPix;
3126 else
3127 nMaxRight=lNullPix+CalcPropMaxRight(nIdx);
3129 else
3130 nMaxRight = pBorders[nIdx].nMaxPos + lNullPix;
3132 nMaxLeft += lMinFrame;
3133 nMaxRight -= lMinFrame;
3136 else
3138 if(nLeftCol==USHRT_MAX)
3139 nMaxLeft=lNullPix;
3140 else
3141 nMaxLeft = pBorders[nLeftCol].nPos +
3142 pBorders[nLeftCol].nWidth + lNullPix;
3144 if(nActRightCol == nIdx)
3146 if(bRTL)
3148 nMaxLeft += pBorders[nIdx].nPos +
3149 GetRightIndent() - Max(GetFirstLineIndent(),
3150 GetLeftIndent());
3151 if(nActLeftCol!=USHRT_MAX)
3152 nMaxLeft -= pBorders[nActLeftCol].nPos +
3153 pBorders[nActLeftCol].nWidth;
3155 else
3157 nMaxLeft += pBorders[nIdx].nPos -
3158 GetRightIndent() + Max(GetFirstLineIndent(),
3159 GetLeftIndent());
3160 if(nActLeftCol!=USHRT_MAX)
3161 nMaxLeft -= pBorders[nActLeftCol].nPos +
3162 pBorders[nActLeftCol].nWidth;
3165 nMaxLeft += lMinFrame;
3166 nMaxLeft += nDragOffset;
3168 // nMaxRight
3169 // linear / proprotional verschieben
3170 if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType||
3171 (DRAG_OBJECT_SIZE_LINEAR & nDragType) )
3173 nMaxRight=lNullPix+CalcPropMaxRight(nIdx);
3175 else if(DRAG_OBJECT_SIZE_LINEAR & nDragType)
3177 nMaxRight=lNullPix+GetMargin2()-GetMargin1()+
3178 (nBorderCount-nIdx-1)*lMinFrame;
3180 else
3182 if(nRightCol==USHRT_MAX)
3183 { // letzte Spalte
3184 nMaxRight = GetMargin2() + lNullPix;
3185 if(IsActLastColumn())
3187 if(bRTL)
3189 nMaxRight -=
3190 GetMargin2() + GetRightIndent() -
3191 Max(GetFirstLineIndent(),
3192 GetLeftIndent());
3194 else
3196 nMaxRight -=
3197 GetMargin2() - GetRightIndent() +
3198 Max(GetFirstLineIndent(),
3199 GetLeftIndent());
3201 nMaxRight += pBorders[nIdx].nPos +
3202 pBorders[nIdx].nWidth;
3205 else
3207 nMaxRight = lNullPix + pBorders[nRightCol].nPos;
3208 USHORT nNotHiddenRightCol =
3209 GetActRightColumn(TRUE, nIdx);
3211 if( nActLeftCol == nIdx )
3213 long nBorder = nNotHiddenRightCol ==
3214 USHRT_MAX ?
3215 GetMargin2() :
3216 pBorders[nNotHiddenRightCol].nPos;
3217 if(bRTL)
3219 nMaxRight -= nBorder + GetRightIndent() -
3220 Max(GetFirstLineIndent(),
3221 GetLeftIndent());
3223 else
3225 nMaxRight -= nBorder - GetRightIndent() +
3226 Max(GetFirstLineIndent(),
3227 GetLeftIndent());
3229 nMaxRight += pBorders[nIdx].nPos +
3230 pBorders[nIdx].nWidth;
3233 nMaxRight -= lMinFrame;
3234 nMaxRight -= pBorders[nIdx].nWidth;
3238 // ObjectItem
3239 else
3241 if(pObjectItem->HasLimits())
3243 if(CalcLimits(nMaxLeft, nMaxRight, nIdx & 1? FALSE: TRUE))
3245 nMaxLeft = ConvertPosPixel(nMaxLeft);
3246 nMaxRight = ConvertPosPixel(nMaxRight);
3249 else
3251 nMaxLeft = LONG_MIN;
3252 nMaxRight = LONG_MAX;
3255 break;
3257 case RULER_DRAGSIZE_2:
3259 nMaxLeft = lNullPix + pBorders[nIdx].nPos;
3260 if(nIdx == pColumnItem->Count()-2) { // letzte Spalte
3261 nMaxRight = GetMargin2() + lNullPix;
3262 if(pColumnItem->IsLastAct()) {
3263 nMaxRight -=
3264 GetMargin2() - GetRightIndent() +
3265 Max(GetFirstLineIndent(),
3266 GetLeftIndent());
3267 nMaxRight += pBorders[nIdx].nPos +
3268 pBorders[nIdx].nWidth;
3271 else {
3272 nMaxRight = lNullPix + pBorders[nIdx+1].nPos;
3273 if(pColumnItem->GetActColumn()-1 == nIdx) {
3274 nMaxRight -= pBorders[nIdx+1].nPos - GetRightIndent() +
3275 Max(GetFirstLineIndent(),
3276 GetLeftIndent());
3277 nMaxRight += pBorders[nIdx].nPos +
3278 pBorders[nIdx].nWidth;
3281 nMaxRight -= lMinFrame;
3282 nMaxRight -= pBorders[nIdx].nWidth;
3283 break;
3286 nMaxRight += nDragOffset;
3287 break;
3289 case RULER_TYPE_INDENT:
3291 const USHORT nIdx = GetDragAryPos();
3292 switch(nIdx) {
3293 case INDENT_FIRST_LINE - INDENT_GAP:
3294 case INDENT_LEFT_MARGIN - INDENT_GAP:
3296 if(bRTL)
3298 nMaxLeft = lNullPix + GetRightIndent();
3300 if(pColumnItem && !pColumnItem->IsFirstAct())
3301 nMaxLeft += pBorders[pColumnItem->GetActColumn()-1].nPos +
3302 pBorders[pColumnItem->GetActColumn()-1].nWidth;
3303 nMaxRight = lNullPix + GetMargin2();
3305 // zusammem draggen
3306 if((INDENT_FIRST_LINE - INDENT_GAP) != nIdx &&
3307 (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
3308 DRAG_OBJECT_LEFT_INDENT_ONLY)
3310 if(GetLeftIndent() > GetFirstLineIndent())
3311 nMaxLeft += GetLeftIndent() - GetFirstLineIndent();
3312 else
3313 nMaxRight -= GetFirstLineIndent() - GetLeftIndent();
3316 else
3318 nMaxLeft = lNullPix;
3320 if(pColumnItem && !pColumnItem->IsFirstAct())
3321 nMaxLeft += pBorders[pColumnItem->GetActColumn()-1].nPos +
3322 pBorders[pColumnItem->GetActColumn()-1].nWidth;
3323 nMaxRight = lNullPix + GetRightIndent() - lMinFrame;
3325 // zusammem draggen
3326 if((INDENT_FIRST_LINE - INDENT_GAP) != nIdx &&
3327 (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
3328 DRAG_OBJECT_LEFT_INDENT_ONLY)
3330 if(GetLeftIndent() > GetFirstLineIndent())
3331 nMaxLeft += GetLeftIndent() - GetFirstLineIndent();
3332 else
3333 nMaxRight -= GetFirstLineIndent() - GetLeftIndent();
3337 break;
3338 case INDENT_RIGHT_MARGIN - INDENT_GAP:
3340 if(bRTL)
3342 nMaxLeft = lNullPix;
3343 nMaxRight = lNullPix + Min(GetFirstLineIndent(), GetLeftIndent()) - lMinFrame;
3344 if(pColumnItem)
3346 USHORT nRightCol=GetActRightColumn( TRUE );
3347 if(!IsActLastColumn( TRUE ))
3348 nMaxRight += pBorders[nRightCol].nPos;
3349 else
3350 nMaxRight += GetMargin2();
3352 else
3353 nMaxLeft += GetMargin1();
3354 nMaxLeft += lMinFrame;
3356 else
3358 nMaxLeft = lNullPix +
3359 Max(GetFirstLineIndent(), GetLeftIndent());
3360 nMaxRight = lNullPix;
3361 if(pColumnItem)
3363 USHORT nRightCol=GetActRightColumn( TRUE );
3364 if(!IsActLastColumn( TRUE ))
3365 nMaxRight += pBorders[nRightCol].nPos;
3366 else
3367 nMaxRight += GetMargin2();
3369 else
3370 nMaxRight += GetMargin2();
3371 nMaxLeft += lMinFrame;
3374 break;
3376 break;
3378 case RULER_TYPE_TAB: // Tabs (Modifier)
3380 links = NOf + Max(LAR, EZ)
3381 rechts = NOf + RAR
3383 nMaxLeft = bRTL ? lNullPix + GetRightIndent()
3384 : lNullPix + Min(GetFirstLineIndent(), GetLeftIndent());
3385 pRuler_Imp->lMaxRightLogic=GetLogicRightIndent()+lLogicNullOffset;
3386 nMaxRight = ConvertSizePixel(pRuler_Imp->lMaxRightLogic);
3387 break;
3388 default: ; //prevent warning
3390 #ifdef DEBUGLIN
3392 String aStr("MinLeft: ");
3393 Size aSize(nMaxLeft + lNullPix, 0);
3394 Size aSize2(nMaxRight + lNullPix, 0);
3395 aSize = pEditWin->PixelToLogic(aSize, MapMode(MAP_MM));
3396 aSize2 = pEditWin->PixelToLogic(aSize2, MapMode(MAP_MM));
3397 aStr += String(aSize.Width());
3398 aStr += " MaxRight: ";
3399 aStr += String(aSize2.Width());
3400 InfoBox(0, aStr).Execute();
3402 #endif
3406 long __EXPORT SvxRuler::StartDrag()
3409 [Beschreibung]
3411 Beginn eines Drag-Vorgangs (SV-Handler); wertet Modifier aus
3412 und berechnet Grenzwerte
3414 [Querverweise]
3416 <SvxRuler::EvalModifier()>
3417 <SvxRuler::CalcMinMax()>
3418 <SvxRuler::EndDrag()>
3423 BOOL bContentProtected = pRuler_Imp->aProtectItem.IsCntntProtected();
3424 if(!bValid)
3425 return FALSE;
3427 pRuler_Imp->lLastLMargin=GetMargin1();
3428 pRuler_Imp->lLastRMargin=GetMargin2();
3429 long bOk = 1;
3430 if(GetStartDragHdl().IsSet())
3431 bOk = Ruler::StartDrag();
3432 if(bOk) {
3433 lInitialDragPos = GetDragPos();
3434 switch(GetDragType()) {
3435 case RULER_TYPE_MARGIN1: // linker Rand umgebender Frame
3436 case RULER_TYPE_MARGIN2: // rechter Rand umgebender Frame
3437 if((bHorz && pLRSpaceItem) || (!bHorz && pULSpaceItem))
3439 if(pColumnItem)
3440 EvalModifier();
3441 else
3442 nDragType = DRAG_OBJECT;
3444 else
3445 bOk = FALSE;
3446 break;
3447 case RULER_TYPE_BORDER: // Tabelle, Spalten (Modifier)
3448 if(pColumnItem)
3450 nDragOffset = pColumnItem->IsTable()? 0 :
3451 GetDragPos() - pBorders[GetDragAryPos()].nPos;
3452 EvalModifier();
3455 else
3456 nDragOffset = 0;
3457 break;
3458 case RULER_TYPE_INDENT: { // Absatzeinzuege (Modifier)
3459 if( bContentProtected )
3460 return FALSE;
3461 USHORT nIndent = INDENT_LEFT_MARGIN;
3462 if((nIndent) == GetDragAryPos() + INDENT_GAP) { // Linker Absatzeinzug
3463 pIndents[0] = pIndents[INDENT_FIRST_LINE];
3464 pIndents[0].nStyle |= RULER_STYLE_DONTKNOW;
3465 EvalModifier();
3467 else
3468 nDragType = DRAG_OBJECT;
3469 pIndents[1] = pIndents[GetDragAryPos()+INDENT_GAP];
3470 pIndents[1].nStyle |= RULER_STYLE_DONTKNOW;
3471 break;
3473 case RULER_TYPE_TAB: // Tabs (Modifier)
3474 if( bContentProtected ) return FALSE;
3475 EvalModifier();
3476 pTabs[0] = pTabs[GetDragAryPos()+1];
3477 pTabs[0].nStyle |= RULER_STYLE_DONTKNOW;
3478 break;
3479 default:
3480 nDragType = NONE;
3483 else
3484 nDragType = NONE;
3485 if(bOk)
3486 CalcMinMax();
3487 return bOk;
3491 void __EXPORT SvxRuler::Drag()
3493 [Beschreibung]
3495 SV-Draghandler
3499 if(IsDragCanceled())
3501 Ruler::Drag();
3502 return;
3504 switch(GetDragType()) {
3505 case RULER_TYPE_MARGIN1: // linker Rand umgebender Frame
3506 DragMargin1();
3507 pRuler_Imp->lLastLMargin=GetMargin1();
3508 break;
3509 case RULER_TYPE_MARGIN2: // rechter Rand umgebender Frame
3510 DragMargin2();
3511 pRuler_Imp->lLastRMargin = GetMargin2();
3512 break;
3513 case RULER_TYPE_INDENT: // Absatzeinzuege
3514 DragIndents();
3515 break;
3516 case RULER_TYPE_BORDER: // Tabelle, Spalten
3517 if(pColumnItem)
3518 DragBorders();
3519 else if(pObjectItem)
3520 DragObjectBorder();
3521 break;
3522 case RULER_TYPE_TAB: // Tabs
3523 DragTabs();
3524 break;
3525 default: ;//prevent warning
3527 Ruler::Drag();
3531 void __EXPORT SvxRuler::EndDrag()
3533 [Beschreibung]
3535 SV-Handler; wird beim Beenden des Draggens gerufen.
3536 Stoesst die Aktualisierung der Daten der Applikation an, indem
3537 durch Aufruf der jeweiligen Apply...()- Methoden die Daten an die
3538 Applikation geschickt werden.
3542 const BOOL bUndo = IsDragCanceled();
3543 const long lPos = GetDragPos();
3544 DrawLine_Impl(lTabPos, 6, bHorz);
3545 lTabPos=-1;
3546 if(!bUndo)
3547 switch(GetDragType())
3549 case RULER_TYPE_MARGIN1: // linker, oberer Rand umgebender Frame
3550 case RULER_TYPE_MARGIN2: // rechter, unterer Rand umgebender Frame
3552 if(!pColumnItem || !pColumnItem->IsTable())
3553 ApplyMargins();
3555 if(pColumnItem &&
3556 (pColumnItem->IsTable() ||
3557 (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)))
3558 ApplyBorders();
3561 break;
3562 case RULER_TYPE_BORDER: // Tabelle, Spalten
3563 if(lInitialDragPos != lPos ||
3564 (pRuler_Imp->bIsTableRows && bHorz)) //special case - the null offset is changed here
3566 if(pColumnItem)
3568 ApplyBorders();
3569 if(bHorz)
3570 UpdateTabs();
3572 else if(pObjectItem)
3573 ApplyObject();
3575 break;
3576 case RULER_TYPE_INDENT: // Absatzeinzuege
3577 if(lInitialDragPos != lPos)
3578 ApplyIndents();
3579 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
3580 break;
3581 case RULER_TYPE_TAB: // Tabs
3583 ApplyTabs();
3584 pTabs[GetDragAryPos()].nStyle &= ~RULER_STYLE_INVISIBLE;
3585 SetTabs(nTabCount, pTabs+TAB_GAP);
3587 break;
3588 default: ; //prevent warning
3590 nDragType = NONE;
3591 Ruler::EndDrag();
3592 if(bUndo)
3593 for(USHORT i=0;i<pRuler_Imp->nControlerItems;i++)
3595 pCtrlItem[i]->ClearCache();
3596 pCtrlItem[i]->GetBindings().Invalidate(pCtrlItem[i]->GetId());
3597 // pCtrlItem[i]->UnBind();
3598 // pCtrlItem[i]->ReBind();
3603 void __EXPORT SvxRuler::ExtraDown()
3606 [Beschreibung]
3608 Ueberladene SV-Methode; setzt den neuen Typ fuer den Defaulttabulator.
3612 // Tabulator Typ umschalten
3613 if(pTabStopItem &&
3614 (nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS) {
3615 ++nDefTabType;
3616 if(RULER_TAB_DEFAULT == nDefTabType)
3617 nDefTabType = RULER_TAB_LEFT;
3618 SetExtraType(RULER_EXTRA_TAB, nDefTabType);
3620 Ruler::ExtraDown();
3624 void __EXPORT SvxRuler::Notify(SfxBroadcaster&, const SfxHint& rHint)
3627 [Beschreibung]
3629 Benachrichtigung durch die Bindings, dass die Statusaktualisierung
3630 beendet ist.
3631 Das Lineal aktualisiert seine Darstellung und meldet sich bei den
3632 Bindings wieder ab.
3637 // Aktualisierung anstossen
3638 if(bActive &&
3639 rHint.Type() == TYPE(SfxSimpleHint) &&
3640 ((SfxSimpleHint&) rHint ).GetId() == SFX_HINT_UPDATEDONE ) {
3641 Update();
3642 EndListening(*pBindings);
3643 bValid = TRUE;
3644 bListening = FALSE;
3649 IMPL_LINK_INLINE_START( SvxRuler, MenuSelect, Menu *, pMenu )
3652 [Beschreibung]
3654 Handler des Kontextmenues fuer das Umschalten der Masseinheit
3659 SetUnit(FieldUnit(pMenu->GetCurItemId()));
3660 return 0;
3662 IMPL_LINK_INLINE_END( SvxRuler, MenuSelect, Menu *, pMenu )
3665 IMPL_LINK( SvxRuler, TabMenuSelect, Menu *, pMenu )
3668 [Beschreibung]
3670 Handler des Tabulatormenues fuer das Setzen des Typs
3675 if(pTabStopItem && pTabStopItem->Count() > pRuler_Imp->nIdx)
3677 SvxTabStop aTabStop = (*pTabStopItem)[pRuler_Imp->nIdx];
3678 aTabStop.GetAdjustment() = ToAttrTab_Impl(pMenu->GetCurItemId()-1);
3679 pTabStopItem->Remove(pRuler_Imp->nIdx);
3680 pTabStopItem->Insert(aTabStop);
3681 USHORT nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
3682 pBindings->GetDispatcher()->Execute( nTabStopId, SFX_CALLMODE_RECORD, pTabStopItem, 0L );
3683 UpdateTabs();
3684 pRuler_Imp->nIdx = 0;
3686 return 0;
3690 void SvxRuler::Command( const CommandEvent& rCEvt )
3693 [Beschreibung]
3695 Mauskontextmenue fuer das Umschalten der Masseinheit
3700 if ( COMMAND_CONTEXTMENU == rCEvt.GetCommand() )
3702 CancelDrag();
3703 BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
3704 if ( pTabs &&
3705 RULER_TYPE_TAB ==
3706 GetType( rCEvt.GetMousePosPixel(), &pRuler_Imp->nIdx ) &&
3707 pTabs[pRuler_Imp->nIdx+TAB_GAP].nStyle < RULER_TAB_DEFAULT )
3709 PopupMenu aMenu;
3710 aMenu.SetSelectHdl(LINK(this, SvxRuler, TabMenuSelect));
3711 VirtualDevice aDev;
3712 const Size aSz(RULER_TAB_WIDTH+2, RULER_TAB_HEIGHT+2);
3713 aDev.SetOutputSize(aSz);
3714 aDev.SetBackground(Wallpaper(Color(COL_WHITE)));
3715 const Point aPt(aSz.Width() / 2, aSz.Height() / 2);
3717 for ( USHORT i = RULER_TAB_LEFT; i < RULER_TAB_DEFAULT; ++i )
3719 USHORT nStyle = bRTL ? i|RULER_TAB_RTL : i;
3720 nStyle |= (USHORT)(bHorz ? WB_HORZ : WB_VERT);
3721 DrawTab(&aDev, aPt, nStyle);
3722 aMenu.InsertItem(i+1,
3723 String(ResId(RID_SVXSTR_RULER_START+i, DIALOG_MGR())),
3724 Image(aDev.GetBitmap(Point(), aSz), Color(COL_WHITE)));
3725 aMenu.CheckItem(i+1, i == pTabs[pRuler_Imp->nIdx+TAB_GAP].nStyle);
3726 aDev.SetOutputSize(aSz); // device loeschen
3728 aMenu.Execute( this, rCEvt.GetMousePosPixel() );
3730 else
3732 PopupMenu aMenu(ResId(RID_SVXMN_RULER, DIALOG_MGR()));
3733 aMenu.SetSelectHdl(LINK(this, SvxRuler, MenuSelect));
3734 FieldUnit eUnit = GetUnit();
3735 const USHORT nCount = aMenu.GetItemCount();
3737 BOOL bReduceMetric = 0 != (nFlags &SVXRULER_SUPPORT_REDUCED_METRIC);
3738 for ( USHORT i = nCount; i; --i )
3740 const USHORT nId = aMenu.GetItemId(i - 1);
3741 aMenu.CheckItem(nId, nId == (USHORT)eUnit);
3742 if(bReduceMetric &&
3743 (nId == FUNIT_M ||
3744 nId == FUNIT_KM ||
3745 nId == FUNIT_FOOT ||
3746 nId == FUNIT_MILE ||
3747 nId == FUNIT_CHAR ||
3748 nId == FUNIT_LINE ))
3749 if (( nId == FUNIT_CHAR ) && bHorz )
3751 else if (( nId == FUNIT_LINE ) && !bHorz )
3753 else
3754 aMenu.RemoveItem(i - 1);
3756 aMenu.Execute( this, rCEvt.GetMousePosPixel() );
3759 else
3760 Ruler::Command( rCEvt );
3764 USHORT SvxRuler::GetActRightColumn(
3765 BOOL bForceDontConsiderHidden, USHORT nAct ) const
3767 if( nAct == USHRT_MAX )
3768 nAct = pColumnItem->GetActColumn();
3769 else nAct++; //Damit man die ActDrag uebergeben kann
3771 BOOL bConsiderHidden = !bForceDontConsiderHidden &&
3772 !( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
3774 while( nAct < pColumnItem->Count() - 1 )
3776 if( (*pColumnItem)[nAct].bVisible || bConsiderHidden )
3777 return nAct;
3778 else
3779 nAct++;
3781 return USHRT_MAX;
3786 USHORT SvxRuler::GetActLeftColumn(
3787 BOOL bForceDontConsiderHidden, USHORT nAct ) const
3789 if(nAct==USHRT_MAX)
3790 nAct=pColumnItem->GetActColumn();
3792 USHORT nLOffs=1;
3794 BOOL bConsiderHidden = !bForceDontConsiderHidden &&
3795 !( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
3797 while(nAct>=nLOffs)
3799 if( (*pColumnItem)[ nAct - nLOffs ].bVisible || bConsiderHidden )
3800 return nAct-nLOffs;
3801 else
3802 nLOffs++;
3804 return USHRT_MAX;
3808 BOOL SvxRuler::IsActLastColumn(
3809 BOOL bForceDontConsiderHidden, USHORT nAct) const
3811 return GetActRightColumn(bForceDontConsiderHidden, nAct)==USHRT_MAX;
3814 BOOL SvxRuler::IsActFirstColumn(
3815 BOOL bForceDontConsiderHidden, USHORT nAct) const
3817 return GetActLeftColumn(bForceDontConsiderHidden, nAct)==USHRT_MAX;
3820 long SvxRuler::CalcPropMaxRight(USHORT nCol) const
3823 if(!(nDragType & DRAG_OBJECT_SIZE_LINEAR))
3826 // ausgehend vom rechten Rand die Mindestbreiten
3827 // aller betroffenen Spalten abziehen
3828 long _nMaxRight = GetMargin2()-GetMargin1();
3830 long lFences=0;
3831 long lMinSpace=USHRT_MAX;
3832 long lOldPos;
3833 long lColumns=0;
3834 USHORT nStart;
3835 if(!pColumnItem->IsTable())
3837 if(nCol==USHRT_MAX)
3839 lOldPos=GetMargin1();
3840 nStart=0;
3842 else
3844 lOldPos=pBorders[nCol].nPos+pBorders[nCol].nWidth;
3845 nStart=nCol+1;
3846 lFences=pBorders[nCol].nWidth;
3849 for(USHORT i = nStart; i < nBorderCount-1; ++i)
3851 long lWidth=pBorders[i].nPos-lOldPos;
3852 lColumns+=lWidth;
3853 if(lWidth<lMinSpace)
3854 lMinSpace=lWidth;
3855 lOldPos=pBorders[i].nPos+pBorders[i].nWidth;
3856 lFences+=pBorders[i].nWidth;
3858 long lWidth=GetMargin2()-lOldPos;
3859 lColumns+=lWidth;
3860 if(lWidth<lMinSpace)
3861 lMinSpace=lWidth;
3863 else
3865 USHORT nActCol;
3866 if(nCol==USHRT_MAX) //CalcMinMax fuer LeftMargin
3868 lOldPos=GetMargin1();
3870 else
3872 lOldPos=pBorders[nCol].nPos;
3874 lColumns=GetMargin2()-lOldPos;
3875 nActCol=nCol;
3876 lFences=0;
3877 while(nActCol<nBorderCount||nActCol==USHRT_MAX)
3879 USHORT nRight;
3880 if(nActCol==USHRT_MAX)
3882 nRight=0;
3883 while(!(*pColumnItem)[nRight].bVisible)
3884 nRight++;
3886 else
3887 nRight=GetActRightColumn(FALSE, nActCol);
3888 long lWidth;
3889 if(nRight!=USHRT_MAX)
3891 lWidth=pBorders[nRight].nPos-lOldPos;
3892 lOldPos=pBorders[nRight].nPos;
3894 else
3895 lWidth=GetMargin2()-lOldPos;
3896 nActCol=nRight;
3897 if(lWidth<lMinSpace)
3898 lMinSpace=lWidth;
3899 if(nActCol==USHRT_MAX)
3900 break;
3904 _nMaxRight-=(long)(lFences+lMinFrame/(float)lMinSpace*lColumns);
3905 return _nMaxRight;
3907 else
3909 if(pColumnItem->IsTable())
3911 USHORT nVisCols=0;
3912 for(USHORT i=GetActRightColumn(FALSE, nCol);i<nBorderCount;)
3914 if((*pColumnItem)[i].bVisible)
3915 nVisCols++;
3916 i=GetActRightColumn(FALSE, i);
3918 return GetMargin2()-GetMargin1()-(nVisCols+1)*lMinFrame;
3920 else
3922 long lWidth=0;
3923 for(USHORT i=nCol;i<nBorderCount-1;i++)
3925 lWidth+=lMinFrame+pBorders[i].nWidth;
3927 return GetMargin2()-GetMargin1()-lWidth;
3931 /*-- 29.11.2007 08:24:23---------------------------------------------------
3932 //#i24363# tab stops relative to indent
3933 -----------------------------------------------------------------------*/
3934 void SvxRuler::SetTabsRelativeToIndent( BOOL bRel )
3936 pRuler_Imp->bIsTabsRelativeToIndent = bRel;