1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: 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 ---------------------------------------------------------------
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"
59 #include <vcl/svapp.hxx>
62 #define RULER_TAB_RTL ((USHORT)0x0010)
65 // STATIC DATA -----------------------------------------------------------
67 #define CTRL_ITEM_COUNT 14
69 #define OBJECT_BORDER_COUNT 4
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)
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();
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
) {
98 aTmp
+= String(ToMM(pWin
, rColItem
[i
].nStart
));
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();
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();
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: ");
130 for(USHORT i
= 0; i
< rTabs
.Count(); ++i
)
132 aTmp
+= String(rTabs
[i
].GetTabPos() / 56);
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;
145 aTmp
+= rLRSpace
.GetTxtFirstLineOfst() / 56;
146 InfoBox(0, aTmp
).Execute();
151 #include <vcl/svapp.hxx>
152 #include <vcl/lstbox.hxx>
153 class RulerDebugWindow
: public Window
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
);
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()));
174 ListBox
& GetLBox() {return aBox
;}
175 static void AddDebugText(const sal_Char
* pDescription
, const String
& rText
);
177 static RulerDebugWindow
* pDebugWindow
= 0;
179 RulerDebugWindow::~RulerDebugWindow()
183 void RulerDebugWindow::AddDebugText(const sal_Char
* pDescription
, const String
& rText
)
187 Window
* pParent
= Application::GetFocusWindow();
188 while(pParent
->GetParent())
189 pParent
= pParent
->GetParent();
190 pDebugWindow
= new RulerDebugWindow(pParent
);
192 String
sContent(String::CreateFromAscii(pDescription
));
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; \
207 #define ADD_DEBUG_TEXT(cDescription, sValue)
208 #define REMOVE_DEBUG_WINDOW
211 struct SvxRuler_Impl
{
221 SvxProtectItem aProtectItem
;
222 SfxBoolItem
* pTextRTLItem
;
223 USHORT nControlerItems
;
225 USHORT nColLeftPix
, nColRightPix
; // Pixelwerte fuer linken / rechten Rand
226 // bei Spalten; gepuffert, um Umrechenfehler
228 // Muesste vielleicht fuer weitere Werte
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?
234 pPercBuf(0), pBlockBuf(0),
235 nPercSize(0), nTotalDist(0),
237 lMaxLeftLogic(0), lMaxRightLogic(0),
238 lLastLMargin(0), lLastRMargin(0),
239 aProtectItem(SID_RULER_PROTECT
),
240 pTextRTLItem(0), nControlerItems(0),
242 nColLeftPix(0), nColRightPix(0),
245 bIsTabsRelativeToIndent(TRUE
)
250 nPercSize
= 0; nTotalDist
= 0;
251 delete[] pPercBuf
; delete[] pBlockBuf
; pPercBuf
= 0;
254 void SetPercSize(USHORT nSize
);
260 void SvxRuler_Impl::SetPercSize(USHORT nSize
)
262 if(nSize
> nPercSize
)
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
287 // erwartet: SvxTabStopItem
290 // SID_ATTR_PARA_LRSPACE
291 // linker, rechter Absatzrand bei H-Lineal
292 // Lineal: SetIndents
295 // Tabellenraender, Spalten
296 // erwartet: so etwas wie SwTabCols
297 // Lineal: SetBorders
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
]),
321 pRuler_Imp(new SvxRuler_Impl
),
322 bAppSetNullOffset(FALSE
), //Wird der 0-Offset des Lineals
323 //durch die appl. gesetzt?
325 lAppNullOffset(LONG_MAX
),
330 nDefTabType(RULER_TAB_LEFT
),
337 pBorders(new RulerBorder
[1]), //wg 1 Spaltiger Tabellen
340 pBindings(&rBindings
),
352 Datenpuffer initialisieren; ControllerItems werden erzeugt
356 memset(pCtrlItem
, 0, sizeof(SvxRulerItem
*) * CTRL_ITEM_COUNT
);
358 rBindings
.EnterRegistrations();
360 // Unterstuetzte Items anlegen
364 pCtrlItem
[i
++] = new SvxRulerItem(SID_RULER_LR_MIN_MAX
, *this, rBindings
);
365 if((nWinStyle
& WB_VSCROLL
) == WB_VSCROLL
)
368 pCtrlItem
[i
++] = new SvxRulerItem(SID_ATTR_LONG_ULSPACE
, *this, rBindings
);
373 pCtrlItem
[i
++] = new SvxRulerItem(SID_ATTR_LONG_LRSPACE
, *this, rBindings
);
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
)))
390 pCtrlItem
[i
++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE
, *this, rBindings
);
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()
445 Freigabe interner Puffer
452 EndListening(*pBindings
);
454 pBindings
->EnterRegistrations();
456 for(USHORT i
= 0; i
< CTRL_ITEM_COUNT
&& pCtrlItem
[i
]; ++i
)
465 delete pParaBorderItem
;
471 delete[] pObjectBorders
;
475 pBindings
->LeaveRegistrations();
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
))
555 long SvxRuler::PixelVAdjust(long nVal
, long nValOld
) const
557 if(ConvertVSizePixel(nVal
)!=ConvertVSizePixel(nValOld
))
563 long SvxRuler::PixelAdjust(long nVal
, long nValOld
) const
565 if(ConvertSizePixel(nVal
)!=ConvertSizePixel(nValOld
))
572 inline USHORT
SvxRuler::GetObjectBordersOff(USHORT nIdx
) const
574 return bHorz
? nIdx
: nIdx
+ 2;
579 void SvxRuler::UpdateFrame()
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
);
610 SetMargin1( ConvertHPosPixel( lAppNullOffset
), nMarginStyle
);
612 // bei Tabelle rechten Rand der Tabelle auswerten
613 if(pColumnItem
&& pColumnItem
->IsTable())
614 lRight
= pColumnItem
->GetRight();
616 lRight
= pLRSpaceItem
->GetRight();
619 ConvertHPosPixel(pPagePosItem
->GetWidth() - lRight
-
620 lLogicNullOffset
+ lAppNullOffset
);
621 SetMargin2( aWidth
, nMarginStyle
);
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
));
635 SetMargin1( 0, nMarginStyle
);
638 SetMargin1( ConvertVPosPixel( lAppNullOffset
),nMarginStyle
);
640 long lLower
= pColumnItem
?
641 pColumnItem
->GetRight() : pULSpaceItem
->GetLower();
643 SetMargin2(ConvertVPosPixel(pPagePosItem
->GetHeight() - lLower
-
644 lLogicNullOffset
+ lAppNullOffset
),
649 // schaltet die Anzeige aus
655 pRuler_Imp
->nColLeftPix
= (USHORT
) ConvertSizePixel(pColumnItem
->GetLeft());
656 pRuler_Imp
->nColRightPix
= (USHORT
) ConvertSizePixel(pColumnItem
->GetRight());
661 void SvxRuler::MouseMove( const MouseEvent
& rMEvt
)
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()
683 StartListening(*pBindings
);
688 void SvxRuler::UpdateFrame
690 const SvxLongLRSpaceItem
*pItem
// neuer Wert LRSpace
696 Neuen Wert fuer LRSpace merken; alten gfs. loeschen
703 delete pLRSpaceItem
; pLRSpaceItem
= 0;
705 pLRSpaceItem
= new SvxLongLRSpaceItem(*pItem
);
706 StartListening_Impl();
711 void SvxRuler::UpdateFrameMinMax
713 const SfxRectangleItem
*pItem
// Werte fuer MinMax
719 Neuen Wert fuer MinMax setzen; alten gfs. loeschen
726 delete pMinMaxItem
; pMinMaxItem
= 0;
728 pMinMaxItem
= new SfxRectangleItem(*pItem
);
733 void SvxRuler::UpdateFrame
735 const SvxLongULSpaceItem
*pItem
// neuer Wert
741 Rechten / unteren Rand aktualisieren
747 if(bActive
&& !bHorz
)
749 delete pULSpaceItem
; pULSpaceItem
= 0;
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
)
767 delete pRuler_Imp
->pTextRTLItem
; pRuler_Imp
->pTextRTLItem
= 0;
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
784 Neuen Wert fuer Spaltendarstellung setzen
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
807 delete pColumnItem
; pColumnItem
= 0;
808 pRuler_Imp
->bIsTableRows
= FALSE
;
810 StartListening_Impl();
815 void SvxRuler::UpdateColumns()
819 Anzeige der Spaltendarstellung aktualisieren
823 if(pColumnItem
&& pColumnItem
->Count() > 1)
825 if( nBorderCount
< pColumnItem
->Count())
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
;
840 if ( !bProtectColumns
)
841 _nFlags
|= RULER_BORDER_SIZEABLE
;
843 USHORT nBorders
= pColumnItem
->Count();
844 if(!pRuler_Imp
->bIsTableRows
)
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
;
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;
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
);
879 void SvxRuler::UpdateObject()
884 Anzeige der Objektdarstellung aktualisieren
891 DBG_ASSERT(pObjectBorders
, "kein Buffer");
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
);
916 void SvxRuler::UpdatePara()
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();
942 pIndents
[INDENT_FIRST_LINE
].nPos
=
945 pParaItem
->GetTxtLeft() -
946 pParaItem
->GetTxtFirstLineOfst() + lAppNullOffset
);
948 pIndents
[INDENT_FIRST_LINE
].nPos
=
951 pParaItem
->GetTxtLeft() +
952 pParaItem
->GetTxtFirstLineOfst() +
954 if( pParaItem
->IsAutoFirst() )
955 pIndents
[INDENT_FIRST_LINE
].nStyle
|= RULER_STYLE_INVISIBLE
;
957 pIndents
[INDENT_FIRST_LINE
].nStyle
&= ~RULER_STYLE_INVISIBLE
;
962 pIndents
[INDENT_LEFT_MARGIN
].nPos
=
965 pParaItem
->GetTxtLeft() + lAppNullOffset
);
967 pIndents
[INDENT_RIGHT_MARGIN
].nPos
=
970 pParaItem
->GetRight() + lAppNullOffset
);
975 pIndents
[INDENT_LEFT_MARGIN
].nPos
=
978 pParaItem
->GetTxtLeft() + lAppNullOffset
);
979 // rechter Rand, immer negativ zum rechten Rand des umgebenden Frames
980 pIndents
[INDENT_RIGHT_MARGIN
].nPos
=
983 pParaItem
->GetRight() + lAppNullOffset
);
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
;
994 pIndents
[INDENT_LEFT_BORDER
].nStyle
= pIndents
[INDENT_RIGHT_BORDER
].nStyle
|= RULER_STYLE_INVISIBLE
;
996 SetIndents(INDENT_COUNT
, pIndents
+INDENT_GAP
);
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
1019 Neuen Wert Absatzeinzuege merken
1025 delete pParaItem
; pParaItem
= 0;
1027 pParaItem
= new SvxLRSpaceItem(*pItem
);
1028 StartListening_Impl();
1031 void SvxRuler::UpdateParaBorder(const SvxLRSpaceItem
* pItem
)
1040 delete pParaBorderItem
; pParaBorderItem
= 0;
1042 pParaBorderItem
= new SvxLRSpaceItem(*pItem
);
1043 StartListening_Impl();
1048 void SvxRuler::UpdatePage()
1053 Anzeige von Postion und Breite der Seite aktualisieren
1060 // alle Objekte werden automatisch angepasst
1063 pEditWin
->LogicToPixel(pPagePosItem
->GetPos()).X(),
1064 pEditWin
->LogicToPixel(Size(pPagePosItem
->GetWidth(),0)).
1068 pEditWin
->LogicToPixel(pPagePosItem
->GetPos()).Y(),
1069 pEditWin
->LogicToPixel(Size(0, pPagePosItem
->GetHeight())).
1071 if(bAppSetNullOffset
)
1072 SetNullOffset(ConvertSizePixel(-lAppNullOffset
+ lLogicNullOffset
));
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();
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
;
1106 void SvxRuler::Update
1108 const SvxPagePosSizeItem
*pItem
// neuer Wert Seitenattribute
1114 Neuen Wert Seitenattribute merken
1121 delete pPagePosItem
; pPagePosItem
= 0;
1123 pPagePosItem
= new SvxPagePosSizeItem(*pItem
);
1124 StartListening_Impl();
1131 void SvxRuler::SetDefTabDist
1133 long l
// Neuer Abstand fuer DefaultTabs in App-Metrik
1139 Neuer Abstand fuer DefaultTabs wird gesetzt
1150 long SvxRuler::GetDefTabDist() const
1155 Wert fuer DefaultTabs erfragen (wird in App.-Methik geliefert)
1164 USHORT
ToSvTab_Impl(SvxTabAdjust eAdj
)
1169 Interne Konvertierungsroutinen zwischen SV-Tab.-Enum und Svx
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
1186 SvxTabAdjust
ToAttrTab_Impl(USHORT 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()
1204 Anzeige der Tabulatoren
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
);
1236 const USHORT nDefTabBuf
= lPosPixel
> lRightIndent
||
1237 lLastTab
> lRightIndent
1239 : (USHORT
)( (lRightIndent
- lPosPixel
) / nDefTabDist
);
1241 if(pTabStopItem
->Count() + TAB_GAP
+ nDefTabBuf
> nTabBufSize
)
1244 // 10 (GAP) auf Vorrat
1245 nTabBufSize
= pTabStopItem
->Count() + TAB_GAP
+ nDefTabBuf
+ GAP
;
1246 pTabs
= new RulerTab
[nTabBufSize
];
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
=
1259 lParaIndent
+ pTab
->GetTabPos() + lAppNullOffset
);
1262 pTabs
[nTabCount
+TAB_GAP
].nPos
= lParaIndentPix
+ lRightPixMargin
- pTabs
[nTabCount
+TAB_GAP
].nPos
;
1264 pTabs
[nTabCount
+TAB_GAP
].nStyle
= ToSvTab_Impl(pTab
->GetAdjustment());
1267 if(!pTabStopItem
->Count())
1268 pTabs
[0].nPos
= bRTL
? lRightPixMargin
: lParaIndentPix
;
1270 // Rest mit Default-Tabs fuellen
1273 for(j
= 0; j
< nDefTabBuf
; ++j
)
1275 pTabs
[nTabCount
+ TAB_GAP
].nPos
=
1276 pTabs
[nTabCount
].nPos
- nDefTabDist
;
1279 pTabs
[nTabCount
+ TAB_GAP
].nPos
-=
1280 ((pTabs
[nTabCount
+ TAB_GAP
].nPos
- lRightPixMargin
)
1282 if(pTabs
[nTabCount
+TAB_GAP
].nPos
<= lParaIndentPix
)
1284 pTabs
[nTabCount
+ TAB_GAP
].nStyle
= RULER_TAB_DEFAULT
;
1290 for(j
= 0; j
< nDefTabBuf
; ++j
)
1292 pTabs
[nTabCount
+ TAB_GAP
].nPos
=
1293 pTabs
[nTabCount
].nPos
+ nDefTabDist
;
1296 pTabs
[nTabCount
+ TAB_GAP
].nPos
-=
1297 ((pTabs
[nTabCount
+ TAB_GAP
].nPos
- lParaIndentPix
)
1299 if(pTabs
[nTabCount
+TAB_GAP
].nPos
>= lRightIndent
)
1301 pTabs
[nTabCount
+ TAB_GAP
].nStyle
= RULER_TAB_DEFAULT
;
1305 SetTabs(nTabCount
, pTabs
+TAB_GAP
);
1306 DBG_ASSERT(nTabCount
+ TAB_GAP
<= nTabBufSize
, "BufferSize zu klein");
1315 void SvxRuler::Update
1317 const SvxTabStopItem
*pItem
// Neuer Wert fuer Tabulatoren
1323 Neuen Wert fuer Tabulatoren merken; alten gfs. loeschen
1330 delete pTabStopItem
; pTabStopItem
= 0;
1333 pTabStopItem
= new SvxTabStopItem(*pItem
);
1335 pTabStopItem
->SetWhich(SID_ATTR_TABSTOP_VERTICAL
);
1337 StartListening_Impl();
1342 void SvxRuler::Update
1344 const SvxObjectItem
*pItem
// Neuer Wert fuer Objekte
1350 Neuen Wert fuer Objekte merken
1357 delete pObjectItem
; pObjectItem
= 0;
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
));
1377 void SvxRuler::Update()
1382 Aktualisierung der Anzeige anstossen
1391 if((nFlags
& SVXRULER_SUPPORT_OBJECT
) == SVXRULER_SUPPORT_OBJECT
)
1396 if(0 != (nFlags
& (SVXRULER_SUPPORT_PARAGRAPH_MARGINS
|SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL
)))
1398 if(0 != (nFlags
& SVXRULER_SUPPORT_TABS
))
1403 inline long SvxRuler::GetPageWidth() const
1405 return bHorz
? pPagePosItem
->GetWidth() : pPagePosItem
->GetHeight();
1410 inline long SvxRuler::GetFrameLeft() const
1415 Erfragen des linken Randes in Pixeln
1421 return bAppSetNullOffset
?
1422 GetMargin1() + ConvertSizePixel(lLogicNullOffset
):
1423 Ruler::GetNullOffset();
1426 inline void SvxRuler::SetFrameLeft(long l
)
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
);
1443 Ruler::SetNullOffset(l
);
1447 long SvxRuler::GetFirstLineIndent() const
1452 Erstzeileneinzug in Pixels erfragen
1456 return pParaItem
? pIndents
[INDENT_FIRST_LINE
].nPos
: GetMargin1();
1460 long SvxRuler::GetLeftIndent() const
1465 Linken Absatzrand in Pixels erfragen
1469 return pParaItem
? pIndents
[INDENT_LEFT_MARGIN
].nPos
: GetMargin1();
1474 long SvxRuler::GetRightIndent() const
1479 Rechten Absatzrand in Pixels erfragen
1483 return pParaItem
? pIndents
[INDENT_RIGHT_MARGIN
].nPos
: GetMargin2();
1487 long SvxRuler::GetLogicRightIndent() const
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!");
1509 pColumnItem
&& pColumnItem
->Count() && pColumnItem
->GetActColumn() < pColumnItem
->Count() ?
1510 (*pColumnItem
)[pColumnItem
->GetActColumn()].nStart
: 0;
1511 if(pParaBorderItem
&& (!pColumnItem
|| pColumnItem
->IsTable()))
1512 nLeft
+= pParaBorderItem
->GetLeft();
1516 inline long SvxRuler::GetLeftMin() const
1518 DBG_ASSERT(pMinMaxItem
, "kein MinMax-Wert gesetzt");
1520 bHorz
? pMinMaxItem
->GetValue().Left(): pMinMaxItem
->GetValue().Top()
1524 inline long SvxRuler::GetRightMax() const
1526 DBG_ASSERT(pMinMaxItem
, "kein MinMax-Wert gesetzt");
1528 bHorz
? pMinMaxItem
->GetValue().Right(): pMinMaxItem
->GetValue().Bottom()
1533 long SvxRuler::GetRightFrameMargin() const
1538 Rechten umgebenden Rand erfragen (in logischen Einheiten)
1545 if(!IsActLastColumn( TRUE
))
1547 long nRet
= (*pColumnItem
)[GetActRightColumn( TRUE
)].nEnd
;
1548 if(pColumnItem
->IsTable() && pParaBorderItem
)
1549 nRet
-= pParaBorderItem
->GetRight();
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();
1569 l
= pPagePosItem
->GetWidth() - l
;
1571 l
= pPagePosItem
->GetHeight() - 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
)
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
1613 Hilfsroutine; alle Tabs um einen festen Wert verschieben
1618 for(USHORT i
= 0; i
< nCount
; ++i
) pTabs
[i
].nPos
+= lDiff
;
1623 void SvxRuler::DragMargin1()
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
);
1635 (//nDragType & DRAG_OBJECT_SIZE_LINEAR ||
1636 nDragType
& DRAG_OBJECT_SIZE_PROPORTIONAL
))
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
);
1667 pObjectBorders
[GetObjectBordersOff(0)].nPos
-= _lDiff
;
1668 pObjectBorders
[GetObjectBordersOff(1)].nPos
-= _lDiff
;
1669 SetBorders(2, pObjectBorders
+ GetObjectBordersOff(0));
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
1681 pIndents
[INDENT_RIGHT_MARGIN
].nPos
-= _lDiff
;
1682 SetIndents(INDENT_COUNT
, pIndents
+INDENT_GAP
);
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
);
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
);
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
1730 pIndents
[INDENT_FIRST_LINE
].nPos
+= _lDiff
;
1731 pIndents
[INDENT_LEFT_MARGIN
].nPos
+= _lDiff
;
1732 SetIndents(INDENT_COUNT
, pIndents
+INDENT_GAP
);
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
);
1748 ModifyTabs_Impl(nTabCount
+TAB_GAP
, pTabs
, _lDiff
);
1749 SetTabs(nTabCount
, pTabs
+TAB_GAP
);
1756 void SvxRuler::DragMargin2()
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
))
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()
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
)
1818 Ausgaberoutine fuer Hilfslinie beim Vereschieben von Tabs, Tabellen-
1825 const long nHeight
= pEditWin
->GetOutputSize().Height();
1826 Point aZero
=pEditWin
->GetMapMode().GetOrigin();
1828 pEditWin
->InvertTracking(
1829 Rectangle( Point(_lTabPos
, -aZero
.Y()),
1830 Point(_lTabPos
, -aZero
.Y()+nHeight
)),
1831 SHOWTRACK_SPLIT
| SHOWTRACK_CLIP
);
1835 _lTabPos
= ConvertHSizeLogic(
1836 GetCorrectedDragPos( ( nNew
&4 ) != 0, ( nNew
&2 ) != 0 ) +
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
);
1848 const long nWidth
= pEditWin
->GetOutputSize().Width();
1849 Point aZero
=pEditWin
->GetMapMode().GetOrigin();
1852 pEditWin
->InvertTracking(
1853 Rectangle( Point(-aZero
.X(), _lTabPos
),
1854 Point(-aZero
.X()+nWidth
, _lTabPos
)),
1855 SHOWTRACK_SPLIT
| SHOWTRACK_CLIP
);
1860 _lTabPos
= ConvertVSizeLogic(GetCorrectedDragPos()+GetNullOffset());
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()
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
;
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
1913 long nDelta
= pRuler_Imp
->nTotalDist
* pRuler_Imp
->pPercBuf
[i
];
1915 pTabs
[i
].nPos
= pTabs
[nIdx
].nPos
+ nDelta
;
1916 if(pTabs
[i
].nPos
+GetNullOffset() > nMaxRight
)
1917 pTabs
[i
].nStyle
|= RULER_STYLE_INVISIBLE
;
1919 pTabs
[i
].nStyle
&= ~RULER_STYLE_INVISIBLE
;
1923 pTabs
[nIdx
].nPos
= lDragPos
;
1926 pTabs
[nIdx
].nStyle
|= RULER_STYLE_INVISIBLE
;
1928 pTabs
[nIdx
].nStyle
&= ~RULER_STYLE_INVISIBLE
;
1929 SetTabs(nTabCount
, pTabs
+TAB_GAP
);
1934 void SvxRuler::SetActive(BOOL bOn
)
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 );*/
1962 pBindings
->EnterRegistrations();
1964 for(USHORT i
=0;i
<pRuler_Imp
->nControlerItems
;i
++)
1965 pCtrlItem
[i
]->ReBind();
1967 for(USHORT j
=0;j
<pRuler_Imp
->nControlerItems
;j
++)
1968 pCtrlItem
[j
]->UnBind();
1969 pBindings
->LeaveRegistrations();
1977 void SvxRuler::UpdateParaContents_Impl
1979 long l
, // Differenz
1980 UpdateType eType
// Art (alle, links oder rechts)
1986 Hilfsroutine; Mitfuehren von Tabulatoren und Absatzraendern
1992 pIndents
[INDENT_RIGHT_MARGIN
].nPos
+= l
;
1995 pIndents
[INDENT_RIGHT_MARGIN
].nPos
+= l
;
1999 pIndents
[INDENT_FIRST_LINE
].nPos
+= l
;
2000 pIndents
[INDENT_LEFT_MARGIN
].nPos
+= l
;
2003 for(USHORT i
= 0; i
< nTabCount
+TAB_GAP
;++i
)
2005 SetTabs(nTabCount
, pTabs
+TAB_GAP
);
2010 SetIndents(INDENT_COUNT
, pIndents
+INDENT_GAP
);
2015 void SvxRuler::DragBorders()
2020 Draggen von Borders (Tabellen- und anderen Spalten)
2024 BOOL bLeftIndentsCorrected
= FALSE
, bRightIndentsCorrected
= FALSE
;
2027 if(GetDragType()==RULER_TYPE_BORDER
)
2029 DrawLine_Impl(lTabPos
, 7, bHorz
);
2030 nIdx
= GetDragAryPos();
2035 USHORT nDragSize
= GetDragSize();
2038 // the drag position has to be corrected to be able to prevent borders from passing each other
2039 long lPos
= GetCorrectedDragPos();
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
)
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
;
2091 lLeft
= pBorders
[nIdx
].nPos
;
2092 pRuler_Imp
->nTotalDist
-= lDiff
;
2098 nStartLimit
= nIdx
- 1;
2099 pRuler_Imp
->nTotalDist
+= lDiff
;
2106 pBorders
[nIdx
].nPos
+= lDiff
;
2107 lLeft
= pBorders
[nIdx
].nPos
;
2108 pRuler_Imp
->nTotalDist
-=lDiff
;
2111 case RULER_TYPE_MARGIN1
:
2113 lLeft
=pRuler_Imp
->lLastLMargin
+lDiff
;
2114 pRuler_Imp
->nTotalDist
-=lDiff
;
2116 case RULER_TYPE_MARGIN2
:
2118 lLeft
= 0;//pRuler_Imp->lLastRMargin + lDiff;
2119 nStartLimit
= nBorderCount
- 2;
2120 pRuler_Imp
->nTotalDist
+= lDiff
;
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
2153 for(int i
= 0; i
< nIdx
; ++i
)
2154 pBorders
[i
].nPos
+= lDiff
;
2155 AdjustMargin1(lDiff
);
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.
2174 if(GetDragType()==RULER_TYPE_BORDER
)
2177 lLeft
=(pBorders
[nIdx
].nPos
+=lDiff
);
2182 lLeft
=pRuler_Imp
->lLastLMargin
+lDiff
;
2184 //in vertical tables the left borders have to be moved
2187 for(int i
= 0; i
< nIdx
; ++i
)
2189 pBorders
[i
].nPos
+= lDiff
;
2191 AdjustMargin1(lDiff
);
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 );
2204 pBorders
[nIdx
].nPos
+=lDiff
;
2207 case RULER_DRAGSIZE_1
:
2209 lDiff
= lPos
- pBorders
[nIdx
].nPos
;
2210 pBorders
[nIdx
].nWidth
+= pBorders
[nIdx
].nPos
- lPos
;
2211 pBorders
[nIdx
].nPos
= lPos
;
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
;
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()
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()
2264 Anwenden von Randeinstellungen; durch Draggen veraendert.
2268 const SfxPoolItem
*pItem
= 0;
2269 USHORT nId
= SID_ATTR_LONG_LRSPACE
;
2272 const long lOldNull
= lLogicNullOffset
;
2273 if(pRuler_Imp
->lMaxLeftLogic
!=-1&&nMaxLeft
==GetMargin1()+Ruler::GetNullOffset())
2274 pLRSpaceItem
->SetLeft(lLogicNullOffset
=pRuler_Imp
->lMaxLeftLogic
);
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
);
2287 pLRSpaceItem
->SetRight(
2289 Max((long)0,pPagePosItem
->GetWidth() -
2290 pLRSpaceItem
->GetLeft() -
2291 (ConvertHPosLogic(GetMargin2()) -
2292 lAppNullOffset
)),pLRSpaceItem
->GetRight()));
2293 pItem
= pLRSpaceItem
;
2295 Debug_Impl(pEditWin
,*pLRSpaceItem
);
2299 const long lOldNull
= lLogicNullOffset
;
2300 pULSpaceItem
->SetUpper(
2303 ConvertVPosLogic(GetFrameLeft()) -
2304 lAppNullOffset
,pULSpaceItem
->GetUpper()));
2305 if(bAppSetNullOffset
)
2306 lAppNullOffset
+= lLogicNullOffset
- lOldNull
;
2307 pULSpaceItem
->SetLower(
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
;
2316 Debug_Impl(pEditWin
,*pULSpaceItem
);
2319 pBindings
->GetDispatcher()->Execute( nId
, SFX_CALLMODE_RECORD
, pItem
, 0L );
2325 void SvxRuler::ApplyIndents()
2329 Anwenden von Absatzeinstellungen; durch Draggen veraendert.
2334 if(pColumnItem
&&!IsActFirstColumn( TRUE
))
2336 long nLeftCol
=GetActLeftColumn( TRUE
);
2340 pIndents
[INDENT_LEFT_MARGIN
].nPos
-
2341 (pBorders
[nLeftCol
].nPos
+
2342 pBorders
[nLeftCol
].nWidth
))-
2343 lAppNullOffset
,pParaItem
->GetTxtLeft());
2348 ConvertHPosLogic(pIndents
[INDENT_LEFT_MARGIN
].nPos
),
2349 pParaItem
->GetTxtLeft());
2351 BOOL bRTL
= pRuler_Imp
->pTextRTLItem
&& pRuler_Imp
->pTextRTLItem
->GetValue();
2353 long nNewFirstLineOffset
;
2356 long nRightFrameMargin
= GetRightFrameMargin();
2357 nNewFirstLineOffset
= PixelHAdjust(nRightFrameMargin
-
2358 ConvertHPosLogic(pIndents
[INDENT_FIRST_LINE
].nPos
) -
2360 pParaItem
->GetTxtFirstLineOfst());
2363 nNewFirstLineOffset
=
2365 ConvertHPosLogic(pIndents
[INDENT_FIRST_LINE
].nPos
-
2366 pIndents
[INDENT_LEFT_MARGIN
].nPos
) -
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
2375 long nLeftFrameMargin
= GetLeftFrameMargin();
2376 long nRightFrameMargin
= GetRightFrameMargin();
2377 nNewTxtLeft
= nRightFrameMargin
- nNewTxtLeft
- nLeftFrameMargin
;
2378 nNewFirstLineOffset
-= nNewTxtLeft
;
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())))
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() ) );
2400 pParaItem
->SetRight(
2403 pBorders
[GetActRightColumn( TRUE
)].nPos
-
2404 pIndents
[INDENT_RIGHT_MARGIN
].nPos
) -
2406 pParaItem
->GetRight()));
2414 pParaItem
->SetRight( PixelHAdjust(
2415 ConvertHPosLogic(GetMargin1() +
2416 pIndents
[INDENT_RIGHT_MARGIN
].nPos
) - GetLeftFrameMargin() +
2417 (pParaBorderItem
? pParaBorderItem
->GetLeft() : 0) -
2418 lAppNullOffset
, pParaItem
->GetRight()));
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 );
2434 void SvxRuler::ApplyTabs()
2438 Anwenden von Tabulatoreinstellungen; durch Draggen veraendert.
2442 BOOL bRTL
= pRuler_Imp
->pTextRTLItem
&& pRuler_Imp
->pTextRTLItem
->GetValue();
2443 const USHORT nCoreIdx
= GetDragAryPos();
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() )
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
-
2475 aTabStop
.GetTabPos());
2476 pItem
->Insert(aTabStop
);
2478 delete pTabStopItem
;
2479 pTabStopItem
= pItem
;
2481 else if( pTabStopItem
->Count() == 0 )
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
;
2493 //#i24363# tab stops relative to indent
2494 const long nTmpLeftIndent
= pRuler_Imp
->bIsTabsRelativeToIndent
?
2496 ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset
);
2498 aTabStop
.GetTabPos() = PixelHAdjust(
2499 ConvertHPosLogic( nTmpLeftIndent
- pTabs
[nCoreIdx
+TAB_GAP
].nPos
) - lAppNullOffset
,
2500 aTabStop
.GetTabPos());
2504 //#i24363# tab stops relative to indent
2505 const long nTmpLeftIndent
= pRuler_Imp
->bIsTabsRelativeToIndent
?
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 );
2523 void SvxRuler::ApplyBorders()
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()));
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
) -
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.
2564 Debug_Impl(pEditWin
,*pColumnItem
);
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()
2577 Anwenden von Objekteinstellungen; durch Draggen veraendert.
2582 long nMargin
= pLRSpaceItem
? pLRSpaceItem
->GetLeft(): 0;
2583 pObjectItem
->SetStartX(
2585 ConvertPosLogic(pObjectBorders
[0].nPos
)
2586 + nMargin
- lAppNullOffset
,pObjectItem
->GetStartX()));
2587 pObjectItem
->SetEndX(
2589 ConvertPosLogic(pObjectBorders
[1].nPos
)
2590 + nMargin
- lAppNullOffset
,pObjectItem
->GetEndX()));
2591 nMargin
= pULSpaceItem
? pULSpaceItem
->GetUpper(): 0;
2592 pObjectItem
->SetStartY(
2594 ConvertPosLogic(pObjectBorders
[2].nPos
)
2595 + nMargin
- lAppNullOffset
,pObjectItem
->GetStartY()));
2596 pObjectItem
->SetEndY(
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
)
2607 Vorbereitung proportionales Draggen; es wird der proportionale
2608 Anteil bezogen auf die Gesamtbreite in Promille berechnet.
2612 pRuler_Imp
->nTotalDist
= GetMargin2();
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());
2626 USHORT nIdx
=GetDragAryPos();
2632 if(eType
!= RULER_TYPE_BORDER
)
2634 lOrigLPos
= GetMargin1();
2640 if(pRuler_Imp
->bIsTableRows
&&!bHorz
)
2642 lOrigLPos
= GetMargin1();
2647 lOrigLPos
= pBorders
[nIdx
].nPos
+ pBorders
[nIdx
].nWidth
;
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
;
2662 nStartBorder
= nIdx
+ 1;
2663 nEndBorder
= pColumnItem
->Count() - 1;
2671 lWidth
= pBorders
[nIdx
].nPos
;
2673 lWidth
= GetMargin2() - lWidth
;
2674 pRuler_Imp
->nTotalDist
= lWidth
;
2675 lPos
= lOrigLPos
= pBorders
[nIdx
].nPos
;
2677 for(USHORT i
= nStartBorder
; i
< nEndBorder
; ++i
)
2681 lActWidth
+= pBorders
[i
].nPos
- lPos
;
2682 lPos
= pBorders
[i
].nPos
+ pBorders
[i
].nWidth
;
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
;
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
;
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
;
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
);
2734 void SvxRuler::EvalModifier()
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
)
2759 nDragType
= DRAG_OBJECT_SIZE_LINEAR
;
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
);
2769 case KEY_MOD1
| KEY_SHIFT
:
2770 if(GetDragType()!=RULER_TYPE_MARGIN1
&&
2771 GetDragType()!=RULER_TYPE_MARGIN2
)
2772 nDragType
= DRAG_OBJECT_ACTLINE_ONLY
;
2774 // alt: Bemassungspfeile
2779 void __EXPORT
SvxRuler::Click()
2784 Ueberladener Handler SV; setzt Tab per Dispatcheraufruf
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();
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
2816 //#i24363# tab stops relative to indent
2818 nTabPos
= ( pRuler_Imp
->bIsTabsRelativeToIndent
?
2820 ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset
) ) -
2824 ( pRuler_Imp
->bIsTabsRelativeToIndent
?
2828 SvxTabStop
aTabStop(ConvertHPosLogic(nTabPos
),
2829 ToAttrTab_Impl(nDefTabType
));
2830 pTabStopItem
->Insert(aTabStop
);
2837 BOOL
SvxRuler::CalcLimits
2839 long &nMax1
, // zu setzenden Minimalwert
2840 long &nMax2
, // zu setzenden Maximalwert
2846 Defaultimplementierung der virtuellen Funktion; kann die Applikation
2847 ueberladen, um eine eigene Grenzwertbehandlung zu implementieren.
2848 Die Werte sind auf die Seite bezogen.
2857 void SvxRuler::CalcMinMax()
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 )
2883 nMaxRight
= lNullPix
- GetRightIndent() +
2884 Max(GetFirstLineIndent(), GetLeftIndent()) -
2889 nMaxRight
= lNullPix
+ GetRightIndent() -
2890 Max(GetFirstLineIndent(), GetLeftIndent()) -
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
;
2905 nMaxRight
= pBorders
[0].nPos
- lMinFrame
+ lNullPix
;
2908 nMaxLeft
= nMaxRight
= lNullPix
;
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(
2921 (pColumnItem
->IsTable() && pLRSpaceItem
)
2922 ? pLRSpaceItem
->GetRight() : 0))
2923 - GetMargin2() + GetMargin1();
2927 nMaxRight
= lNullPix
- lMinFrame
;
2928 if(pColumnItem
->IsFirstAct())
2934 Max(GetFirstLineIndent(), GetLeftIndent()) - GetRightIndent());
2939 pBorders
[0].nPos
, GetRightIndent() -
2940 Max(GetFirstLineIndent(), GetLeftIndent()));
2943 else if( pColumnItem
->Count() > 1 )
2944 nMaxRight
+= pBorders
[0].nPos
;
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());
2959 case RULER_TYPE_MARGIN2
:
2960 { // rechter Rand umgebender Frame
2961 pRuler_Imp
->lMaxRightLogic
=
2963 GetPageWidth() - GetRightMax() : GetPageWidth();
2964 nMaxRight
= ConvertSizePixel(pRuler_Imp
->lMaxRightLogic
);
2971 nMaxLeft
= GetMargin2() + GetRightIndent() -
2972 Max(GetFirstLineIndent(),GetLeftIndent()) - GetMargin1()+
2973 lMinFrame
+ lNullPix
;
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
;
2992 if(nDragType
& DRAG_OBJECT_SIZE_PROPORTIONAL
)
2994 nMaxLeft
= (pColumnItem
->Count()) * lMinFrame
+ lNullPix
;
2998 if(pColumnItem
->Count() > 1)
2999 nMaxLeft
= pBorders
[pColumnItem
->Count() - 2].nPos
+ lMinFrame
+ lNullPix
;
3001 nMaxLeft
= lMinFrame
+ lNullPix
;
3003 if(pColumnItem
->Count() > 1)
3004 nMaxRight
= pBorders
[pColumnItem
->Count() - 2].nMaxPos
+ lNullPix
;
3006 nMaxRight
-= GetRightIndent() - lNullPix
;
3011 nMaxLeft
= lMinFrame
+ lNullPix
;
3012 if(IsActLastColumn() || pColumnItem
->Count() < 2 ) //Falls letzte Spalte aktiv
3016 nMaxLeft
= lMinFrame
+ lNullPix
+ GetMargin2() +
3017 GetRightIndent() - Max(GetFirstLineIndent(),
3022 nMaxLeft
= lMinFrame
+ lNullPix
+ GetMargin2() -
3023 GetRightIndent() + Max(GetFirstLineIndent(),
3027 if( pColumnItem
->Count() >= 2 )
3030 lMinFrame
+ lNullPix
+
3031 pBorders
[pColumnItem
->Count()-2].nPos
+
3032 pBorders
[pColumnItem
->Count()-2].nWidth
;
3033 nMaxLeft
=Max(nMaxLeft
,nNewMaxLeft
);
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
;
3050 nMaxLeft
= lNullPix
;
3052 nMaxLeft
= pBorders
[nIdx
-1].nPos
+
3053 pBorders
[nIdx
-1].nWidth
+ lNullPix
;
3054 if(nIdx
== pColumnItem
->GetActColumn())
3058 nMaxLeft
+= pBorders
[nIdx
].nPos
+
3059 GetRightIndent() - Max(GetFirstLineIndent(),
3064 nMaxLeft
+= pBorders
[nIdx
].nPos
-
3065 GetRightIndent() + Max(GetFirstLineIndent(),
3069 nMaxLeft
-= pBorders
[nIdx
-1].nPos
+
3070 pBorders
[nIdx
-1].nWidth
;
3072 nMaxLeft
+= lMinFrame
;
3073 nMaxLeft
+= nDragOffset
;
3076 case RULER_DRAGSIZE_MOVE
:
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
;
3103 nMaxRight
= nRightCol
== USHRT_MAX
?
3105 pBorders
[nRightCol
].nPos
;
3106 nMaxLeft
+= lNullPix
;
3107 nMaxRight
+= lNullPix
;
3111 if(DRAG_OBJECT_SIZE_PROPORTIONAL
& nDragType
&& !bHorz
&& pRuler_Imp
->bIsTableRows
)
3112 nMaxLeft
= (nIdx
+ 1) * lMinFrame
+ lNullPix
;
3114 nMaxLeft
= pBorders
[nIdx
].nMinPos
+ lNullPix
;
3115 if(DRAG_OBJECT_SIZE_PROPORTIONAL
& nDragType
||
3116 (DRAG_OBJECT_SIZE_LINEAR
& nDragType
) )
3118 if(pRuler_Imp
->bIsTableRows
)
3121 nMaxRight
= GetRightIndent() + lNullPix
-
3122 (pColumnItem
->Count() - nIdx
- 1) * lMinFrame
;
3124 nMaxRight
= pBorders
[nIdx
].nMaxPos
+ lNullPix
;
3127 nMaxRight
=lNullPix
+CalcPropMaxRight(nIdx
);
3130 nMaxRight
= pBorders
[nIdx
].nMaxPos
+ lNullPix
;
3132 nMaxLeft
+= lMinFrame
;
3133 nMaxRight
-= lMinFrame
;
3138 if(nLeftCol
==USHRT_MAX
)
3141 nMaxLeft
= pBorders
[nLeftCol
].nPos
+
3142 pBorders
[nLeftCol
].nWidth
+ lNullPix
;
3144 if(nActRightCol
== nIdx
)
3148 nMaxLeft
+= pBorders
[nIdx
].nPos
+
3149 GetRightIndent() - Max(GetFirstLineIndent(),
3151 if(nActLeftCol
!=USHRT_MAX
)
3152 nMaxLeft
-= pBorders
[nActLeftCol
].nPos
+
3153 pBorders
[nActLeftCol
].nWidth
;
3157 nMaxLeft
+= pBorders
[nIdx
].nPos
-
3158 GetRightIndent() + Max(GetFirstLineIndent(),
3160 if(nActLeftCol
!=USHRT_MAX
)
3161 nMaxLeft
-= pBorders
[nActLeftCol
].nPos
+
3162 pBorders
[nActLeftCol
].nWidth
;
3165 nMaxLeft
+= lMinFrame
;
3166 nMaxLeft
+= nDragOffset
;
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
;
3182 if(nRightCol
==USHRT_MAX
)
3184 nMaxRight
= GetMargin2() + lNullPix
;
3185 if(IsActLastColumn())
3190 GetMargin2() + GetRightIndent() -
3191 Max(GetFirstLineIndent(),
3197 GetMargin2() - GetRightIndent() +
3198 Max(GetFirstLineIndent(),
3201 nMaxRight
+= pBorders
[nIdx
].nPos
+
3202 pBorders
[nIdx
].nWidth
;
3207 nMaxRight
= lNullPix
+ pBorders
[nRightCol
].nPos
;
3208 USHORT nNotHiddenRightCol
=
3209 GetActRightColumn(TRUE
, nIdx
);
3211 if( nActLeftCol
== nIdx
)
3213 long nBorder
= nNotHiddenRightCol
==
3216 pBorders
[nNotHiddenRightCol
].nPos
;
3219 nMaxRight
-= nBorder
+ GetRightIndent() -
3220 Max(GetFirstLineIndent(),
3225 nMaxRight
-= nBorder
- GetRightIndent() +
3226 Max(GetFirstLineIndent(),
3229 nMaxRight
+= pBorders
[nIdx
].nPos
+
3230 pBorders
[nIdx
].nWidth
;
3233 nMaxRight
-= lMinFrame
;
3234 nMaxRight
-= pBorders
[nIdx
].nWidth
;
3241 if(pObjectItem
->HasLimits())
3243 if(CalcLimits(nMaxLeft
, nMaxRight
, nIdx
& 1? FALSE
: TRUE
))
3245 nMaxLeft
= ConvertPosPixel(nMaxLeft
);
3246 nMaxRight
= ConvertPosPixel(nMaxRight
);
3251 nMaxLeft
= LONG_MIN
;
3252 nMaxRight
= LONG_MAX
;
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()) {
3264 GetMargin2() - GetRightIndent() +
3265 Max(GetFirstLineIndent(),
3267 nMaxRight
+= pBorders
[nIdx
].nPos
+
3268 pBorders
[nIdx
].nWidth
;
3272 nMaxRight
= lNullPix
+ pBorders
[nIdx
+1].nPos
;
3273 if(pColumnItem
->GetActColumn()-1 == nIdx
) {
3274 nMaxRight
-= pBorders
[nIdx
+1].nPos
- GetRightIndent() +
3275 Max(GetFirstLineIndent(),
3277 nMaxRight
+= pBorders
[nIdx
].nPos
+
3278 pBorders
[nIdx
].nWidth
;
3281 nMaxRight
-= lMinFrame
;
3282 nMaxRight
-= pBorders
[nIdx
].nWidth
;
3286 nMaxRight
+= nDragOffset
;
3289 case RULER_TYPE_INDENT
:
3291 const USHORT nIdx
= GetDragAryPos();
3293 case INDENT_FIRST_LINE
- INDENT_GAP
:
3294 case INDENT_LEFT_MARGIN
- INDENT_GAP
:
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();
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();
3313 nMaxRight
-= GetFirstLineIndent() - GetLeftIndent();
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
;
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();
3333 nMaxRight
-= GetFirstLineIndent() - GetLeftIndent();
3338 case INDENT_RIGHT_MARGIN
- INDENT_GAP
:
3342 nMaxLeft
= lNullPix
;
3343 nMaxRight
= lNullPix
+ Min(GetFirstLineIndent(), GetLeftIndent()) - lMinFrame
;
3346 USHORT nRightCol
=GetActRightColumn( TRUE
);
3347 if(!IsActLastColumn( TRUE
))
3348 nMaxRight
+= pBorders
[nRightCol
].nPos
;
3350 nMaxRight
+= GetMargin2();
3353 nMaxLeft
+= GetMargin1();
3354 nMaxLeft
+= lMinFrame
;
3358 nMaxLeft
= lNullPix
+
3359 Max(GetFirstLineIndent(), GetLeftIndent());
3360 nMaxRight
= lNullPix
;
3363 USHORT nRightCol
=GetActRightColumn( TRUE
);
3364 if(!IsActLastColumn( TRUE
))
3365 nMaxRight
+= pBorders
[nRightCol
].nPos
;
3367 nMaxRight
+= GetMargin2();
3370 nMaxRight
+= GetMargin2();
3371 nMaxLeft
+= lMinFrame
;
3378 case RULER_TYPE_TAB
: // Tabs (Modifier)
3380 links = NOf + Max(LAR, EZ)
3383 nMaxLeft
= bRTL
? lNullPix
+ GetRightIndent()
3384 : lNullPix
+ Min(GetFirstLineIndent(), GetLeftIndent());
3385 pRuler_Imp
->lMaxRightLogic
=GetLogicRightIndent()+lLogicNullOffset
;
3386 nMaxRight
= ConvertSizePixel(pRuler_Imp
->lMaxRightLogic
);
3388 default: ; //prevent warning
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();
3406 long __EXPORT
SvxRuler::StartDrag()
3411 Beginn eines Drag-Vorgangs (SV-Handler); wertet Modifier aus
3412 und berechnet Grenzwerte
3416 <SvxRuler::EvalModifier()>
3417 <SvxRuler::CalcMinMax()>
3418 <SvxRuler::EndDrag()>
3423 BOOL bContentProtected
= pRuler_Imp
->aProtectItem
.IsCntntProtected();
3427 pRuler_Imp
->lLastLMargin
=GetMargin1();
3428 pRuler_Imp
->lLastRMargin
=GetMargin2();
3430 if(GetStartDragHdl().IsSet())
3431 bOk
= Ruler::StartDrag();
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
))
3442 nDragType
= DRAG_OBJECT
;
3447 case RULER_TYPE_BORDER
: // Tabelle, Spalten (Modifier)
3450 nDragOffset
= pColumnItem
->IsTable()? 0 :
3451 GetDragPos() - pBorders
[GetDragAryPos()].nPos
;
3458 case RULER_TYPE_INDENT
: { // Absatzeinzuege (Modifier)
3459 if( bContentProtected
)
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
;
3468 nDragType
= DRAG_OBJECT
;
3469 pIndents
[1] = pIndents
[GetDragAryPos()+INDENT_GAP
];
3470 pIndents
[1].nStyle
|= RULER_STYLE_DONTKNOW
;
3473 case RULER_TYPE_TAB
: // Tabs (Modifier)
3474 if( bContentProtected
) return FALSE
;
3476 pTabs
[0] = pTabs
[GetDragAryPos()+1];
3477 pTabs
[0].nStyle
|= RULER_STYLE_DONTKNOW
;
3491 void __EXPORT
SvxRuler::Drag()
3499 if(IsDragCanceled())
3504 switch(GetDragType()) {
3505 case RULER_TYPE_MARGIN1
: // linker Rand umgebender Frame
3507 pRuler_Imp
->lLastLMargin
=GetMargin1();
3509 case RULER_TYPE_MARGIN2
: // rechter Rand umgebender Frame
3511 pRuler_Imp
->lLastRMargin
= GetMargin2();
3513 case RULER_TYPE_INDENT
: // Absatzeinzuege
3516 case RULER_TYPE_BORDER
: // Tabelle, Spalten
3519 else if(pObjectItem
)
3522 case RULER_TYPE_TAB
: // Tabs
3525 default: ;//prevent warning
3531 void __EXPORT
SvxRuler::EndDrag()
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
);
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())
3556 (pColumnItem
->IsTable() ||
3557 (nDragType
& DRAG_OBJECT_SIZE_PROPORTIONAL
)))
3562 case RULER_TYPE_BORDER
: // Tabelle, Spalten
3563 if(lInitialDragPos
!= lPos
||
3564 (pRuler_Imp
->bIsTableRows
&& bHorz
)) //special case - the null offset is changed here
3572 else if(pObjectItem
)
3576 case RULER_TYPE_INDENT
: // Absatzeinzuege
3577 if(lInitialDragPos
!= lPos
)
3579 SetIndents(INDENT_COUNT
, pIndents
+INDENT_GAP
);
3581 case RULER_TYPE_TAB
: // Tabs
3584 pTabs
[GetDragAryPos()].nStyle
&= ~RULER_STYLE_INVISIBLE
;
3585 SetTabs(nTabCount
, pTabs
+TAB_GAP
);
3588 default: ; //prevent warning
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()
3608 Ueberladene SV-Methode; setzt den neuen Typ fuer den Defaulttabulator.
3612 // Tabulator Typ umschalten
3614 (nFlags
& SVXRULER_SUPPORT_TABS
) == SVXRULER_SUPPORT_TABS
) {
3616 if(RULER_TAB_DEFAULT
== nDefTabType
)
3617 nDefTabType
= RULER_TAB_LEFT
;
3618 SetExtraType(RULER_EXTRA_TAB
, nDefTabType
);
3624 void __EXPORT
SvxRuler::Notify(SfxBroadcaster
&, const SfxHint
& rHint
)
3629 Benachrichtigung durch die Bindings, dass die Statusaktualisierung
3631 Das Lineal aktualisiert seine Darstellung und meldet sich bei den
3637 // Aktualisierung anstossen
3639 rHint
.Type() == TYPE(SfxSimpleHint
) &&
3640 ((SfxSimpleHint
&) rHint
).GetId() == SFX_HINT_UPDATEDONE
) {
3642 EndListening(*pBindings
);
3649 IMPL_LINK_INLINE_START( SvxRuler
, MenuSelect
, Menu
*, pMenu
)
3654 Handler des Kontextmenues fuer das Umschalten der Masseinheit
3659 SetUnit(FieldUnit(pMenu
->GetCurItemId()));
3662 IMPL_LINK_INLINE_END( SvxRuler
, MenuSelect
, Menu
*, pMenu
)
3665 IMPL_LINK( SvxRuler
, TabMenuSelect
, Menu
*, pMenu
)
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 );
3684 pRuler_Imp
->nIdx
= 0;
3690 void SvxRuler::Command( const CommandEvent
& rCEvt
)
3695 Mauskontextmenue fuer das Umschalten der Masseinheit
3700 if ( COMMAND_CONTEXTMENU
== rCEvt
.GetCommand() )
3703 BOOL bRTL
= pRuler_Imp
->pTextRTLItem
&& pRuler_Imp
->pTextRTLItem
->GetValue();
3706 GetType( rCEvt
.GetMousePosPixel(), &pRuler_Imp
->nIdx
) &&
3707 pTabs
[pRuler_Imp
->nIdx
+TAB_GAP
].nStyle
< RULER_TAB_DEFAULT
)
3710 aMenu
.SetSelectHdl(LINK(this, SvxRuler
, TabMenuSelect
));
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() );
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
);
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
)
3754 aMenu
.RemoveItem(i
- 1);
3756 aMenu
.Execute( this, rCEvt
.GetMousePosPixel() );
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
)
3786 USHORT
SvxRuler::GetActLeftColumn(
3787 BOOL bForceDontConsiderHidden
, USHORT nAct
) const
3790 nAct
=pColumnItem
->GetActColumn();
3794 BOOL bConsiderHidden
= !bForceDontConsiderHidden
&&
3795 !( nDragType
& DRAG_OBJECT_ACTLINE_ONLY
);
3799 if( (*pColumnItem
)[ nAct
- nLOffs
].bVisible
|| bConsiderHidden
)
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();
3831 long lMinSpace
=USHRT_MAX
;
3835 if(!pColumnItem
->IsTable())
3839 lOldPos
=GetMargin1();
3844 lOldPos
=pBorders
[nCol
].nPos
+pBorders
[nCol
].nWidth
;
3846 lFences
=pBorders
[nCol
].nWidth
;
3849 for(USHORT i
= nStart
; i
< nBorderCount
-1; ++i
)
3851 long lWidth
=pBorders
[i
].nPos
-lOldPos
;
3853 if(lWidth
<lMinSpace
)
3855 lOldPos
=pBorders
[i
].nPos
+pBorders
[i
].nWidth
;
3856 lFences
+=pBorders
[i
].nWidth
;
3858 long lWidth
=GetMargin2()-lOldPos
;
3860 if(lWidth
<lMinSpace
)
3866 if(nCol
==USHRT_MAX
) //CalcMinMax fuer LeftMargin
3868 lOldPos
=GetMargin1();
3872 lOldPos
=pBorders
[nCol
].nPos
;
3874 lColumns
=GetMargin2()-lOldPos
;
3877 while(nActCol
<nBorderCount
||nActCol
==USHRT_MAX
)
3880 if(nActCol
==USHRT_MAX
)
3883 while(!(*pColumnItem
)[nRight
].bVisible
)
3887 nRight
=GetActRightColumn(FALSE
, nActCol
);
3889 if(nRight
!=USHRT_MAX
)
3891 lWidth
=pBorders
[nRight
].nPos
-lOldPos
;
3892 lOldPos
=pBorders
[nRight
].nPos
;
3895 lWidth
=GetMargin2()-lOldPos
;
3897 if(lWidth
<lMinSpace
)
3899 if(nActCol
==USHRT_MAX
)
3904 _nMaxRight
-=(long)(lFences
+lMinFrame
/(float)lMinSpace
*lColumns
);
3909 if(pColumnItem
->IsTable())
3912 for(USHORT i
=GetActRightColumn(FALSE
, nCol
);i
<nBorderCount
;)
3914 if((*pColumnItem
)[i
].bVisible
)
3916 i
=GetActRightColumn(FALSE
, i
);
3918 return GetMargin2()-GetMargin1()-(nVisCols
+1)*lMinFrame
;
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
;