LCOV - code coverage report
Current view: top level - svx/source/dialog - svxruler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 452 1631 27.7 %
Date: 2012-08-25 Functions: 40 94 42.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 378 1693 22.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <string.h>
      30                 :            : #include <limits.h>
      31                 :            : #include <tools/shl.hxx>
      32                 :            : #include <vcl/image.hxx>
      33                 :            : #include <svl/eitem.hxx>
      34                 :            : #include <svl/rectitem.hxx>
      35                 :            : #include <sfx2/dispatch.hxx>
      36                 :            : 
      37                 :            : #include <svl/smplhint.hxx>
      38                 :            : 
      39                 :            : #include <svx/dialogs.hrc>
      40                 :            : #include <svx/dialmgr.hxx>
      41                 :            : #include <svx/ruler.hxx>
      42                 :            : #include "rlrcitem.hxx"
      43                 :            : #include "svx/rulritem.hxx"
      44                 :            : #include <editeng/tstpitem.hxx>
      45                 :            : #include <editeng/lrspitem.hxx>
      46                 :            : #include "editeng/protitem.hxx"
      47                 :            : #include <vcl/svapp.hxx>
      48                 :            : #ifndef RULER_TAB_RTL
      49                 :            : #define RULER_TAB_RTL           ((sal_uInt16)0x0010)
      50                 :            : #endif
      51                 :            : 
      52                 :            : // STATIC DATA -----------------------------------------------------------
      53                 :            : 
      54                 :            : #define CTRL_ITEM_COUNT 14
      55                 :            : #define GAP 10
      56                 :            : #define OBJECT_BORDER_COUNT 4
      57                 :            : #define TAB_GAP 1
      58                 :            : #define INDENT_GAP 2
      59                 :            : #define INDENT_FIRST_LINE   4
      60                 :            : #define INDENT_LEFT_MARGIN  5
      61                 :            : #define INDENT_RIGHT_MARGIN 6
      62                 :            : #define INDENT_LEFT_BORDER  2
      63                 :            : #define INDENT_RIGHT_BORDER 3
      64                 :            : #define INDENT_COUNT        5 //without the first two old values
      65                 :            : 
      66                 :            : #define PIXEL_H_ADJUST( l1, l2 ) PixelHAdjust(l1,l2)
      67                 :            : 
      68                 :            : #ifdef DEBUGLIN
      69                 :            : 
      70                 :            : inline long ToMM(Window *pWin, long lVal)
      71                 :            : {
      72                 :            :     return pWin->PixelToLogic(Size(lVal, 0), MapMode(MAP_MM)).Width();
      73                 :            : }
      74                 :            : 
      75                 :            : void Debug_Impl(Window *pWin, SvxColumnItem& rColItem)
      76                 :            : {
      77                 :            :     String aTmp("Aktuell: ");
      78                 :            :     aTmp += rColItem.GetActColumn();
      79                 :            :     aTmp += " ColLeft: ";
      80                 :            :     aTmp +=  String(ToMM(pWin, rColItem.GetLeft()));
      81                 :            :     aTmp += "   ColRight: ";
      82                 :            :     aTmp +=  String(ToMM(pWin, rColItem.GetRight()));
      83                 :            :     for(sal_uInt16 i = 0; i < rColItem.Count(); ++i) {
      84                 :            :         aTmp += " Start: ";
      85                 :            :         aTmp += String(ToMM(pWin, rColItem[i].nStart));
      86                 :            :         aTmp += " End: ";
      87                 :            :         aTmp += String(ToMM(pWin, rColItem[i].nEnd));
      88                 :            :     }
      89                 :            : 
      90                 :            :     InfoBox(0, aTmp).Execute();
      91                 :            : }
      92                 :            : 
      93                 :            : void Debug_Impl(Window *pWin, const SvxLongLRSpaceItem& rLRSpace)
      94                 :            : {
      95                 :            :     String aTmp("Left: ");
      96                 :            :     aTmp += pWin->PixelToLogic(Size(rLRSpace.GetLeft(), 0), MapMode(MAP_MM)).Width();
      97                 :            :     aTmp += "   Right: ";
      98                 :            :     aTmp +=pWin->PixelToLogic(Size(rLRSpace.GetRight(), 0), MapMode(MAP_MM)).Width();
      99                 :            :     InfoBox(0, aTmp).Execute();
     100                 :            : }
     101                 :            : 
     102                 :            : void Debug_Impl(Window *pWin, const SvxLongULSpaceItem& rULSpace)
     103                 :            : {
     104                 :            :     String aTmp("Upper: ");
     105                 :            :     aTmp += pWin->PixelToLogic(Size(rULSpace.GetUpper(), 0), MapMode(MAP_MM)).Width();
     106                 :            :     aTmp += "   Lower: ";
     107                 :            :     aTmp += pWin->PixelToLogic(Size(rULSpace.GetLower(), 0), MapMode(MAP_MM)).Width();
     108                 :            : 
     109                 :            :     InfoBox(0, aTmp).Execute();
     110                 :            : }
     111                 :            : 
     112                 :            : void DebugTabStops_Impl(const SvxTabStopItem& rTabs)
     113                 :            : {
     114                 :            :     String aTmp("Tabs: ");
     115                 :            : 
     116                 :            :     // Delete Def Tabs
     117                 :            :     for(sal_uInt16 i = 0; i < rTabs.Count(); ++i)
     118                 :            :     {
     119                 :            :         aTmp += String(rTabs[i].GetTabPos() / 56);
     120                 :            :         aTmp += " : ";
     121                 :            :     }
     122                 :            :     InfoBox(0, aTmp).Execute();
     123                 :            : }
     124                 :            : 
     125                 :            : void DebugParaMargin_Impl(const SvxLRSpaceItem& rLRSpace)
     126                 :            : {
     127                 :            :     String aTmp("ParaLeft: ");
     128                 :            :     aTmp += rLRSpace.GetTxtLeft() / 56;
     129                 :            :     aTmp += "   ParaRight: ";
     130                 :            :     aTmp += rLRSpace.GetRight() / 56;
     131                 :            :     aTmp += "   FLI: ";
     132                 :            :     aTmp += rLRSpace.GetTxtFirstLineOfst() / 56;
     133                 :            :     InfoBox(0, aTmp).Execute();
     134                 :            : }
     135                 :            : 
     136                 :            : #endif // DEBUGLIN
     137                 :            : #ifdef DEBUG_RULER
     138                 :            : #include <vcl/lstbox.hxx>
     139                 :            : class RulerDebugWindow : public Window
     140                 :            : {
     141                 :            :     ListBox aBox;
     142                 :            : public:
     143                 :            :         RulerDebugWindow(Window* pParent) :
     144                 :            :             Window(pParent, WB_BORDER|WB_SIZEMOVE|WB_DIALOGCONTROL|WB_CLIPCHILDREN|WB_SYSTEMWINDOW),
     145                 :            :             aBox(this, WB_BORDER)
     146                 :            :             {
     147                 :            :                 Size aOutput(200, 400);
     148                 :            :                 SetOutputSizePixel(aOutput);
     149                 :            :                 aBox.SetSizePixel(aOutput);
     150                 :            :                 aBox.Show();
     151                 :            :                 Show();
     152                 :            :                 Size aParentSize(pParent->GetOutputSizePixel());
     153                 :            :                 Size aOwnSize(GetSizePixel());
     154                 :            :                 aParentSize.Width() -= aOwnSize.Width();
     155                 :            :                 aParentSize.Height() -= aOwnSize.Height();
     156                 :            :                 SetPosPixel(Point(aParentSize.Width(), aParentSize.Height()));
     157                 :            :             }
     158                 :            :         ~RulerDebugWindow();
     159                 :            : 
     160                 :            :         ListBox& GetLBox() {return aBox;}
     161                 :            :         static void     AddDebugText(const sal_Char* pDescription, const String& rText );
     162                 :            : };
     163                 :            : static RulerDebugWindow* pDebugWindow = 0;
     164                 :            : 
     165                 :            : RulerDebugWindow::~RulerDebugWindow()
     166                 :            : {
     167                 :            :     pDebugWindow = 0;
     168                 :            : }
     169                 :            : void     RulerDebugWindow::AddDebugText(const sal_Char* pDescription, const String& rText )
     170                 :            : {
     171                 :            :     if(!pDebugWindow)
     172                 :            :     {
     173                 :            :         Window* pParent = Application::GetFocusWindow();
     174                 :            :         while(pParent->GetParent())
     175                 :            :             pParent = pParent->GetParent();
     176                 :            :         pDebugWindow = new RulerDebugWindow(pParent);
     177                 :            :     }
     178                 :            :     String sContent(String::CreateFromAscii(pDescription));
     179                 :            :     sContent += rText;
     180                 :            :     sal_uInt16 nPos = pDebugWindow->GetLBox().InsertEntry(sContent);
     181                 :            :     pDebugWindow->GetLBox().SelectEntryPos(nPos);
     182                 :            :     pDebugWindow->GrabFocus();
     183                 :            : }
     184                 :            : 
     185                 :            : #define ADD_DEBUG_TEXT(cDescription, sValue) \
     186                 :            :     RulerDebugWindow::AddDebugText(cDescription, sValue);
     187                 :            : 
     188                 :            : #define REMOVE_DEBUG_WINDOW \
     189                 :            :     delete pDebugWindow;    \
     190                 :            :     pDebugWindow = 0;
     191                 :            : 
     192                 :            : #else
     193                 :            : #define ADD_DEBUG_TEXT(cDescription, sValue)
     194                 :            : #define REMOVE_DEBUG_WINDOW
     195                 :            : #endif
     196                 :            : 
     197                 :            : struct SvxRuler_Impl  {
     198                 :            :     sal_uInt16 *pPercBuf;
     199                 :            :     sal_uInt16 *pBlockBuf;
     200                 :            :     sal_uInt16 nPercSize;
     201                 :            :     long   nTotalDist;
     202                 :            :     long   lOldWinPos;
     203                 :            :     long   lMaxLeftLogic;
     204                 :            :     long   lMaxRightLogic;
     205                 :            :     long   lLastLMargin;
     206                 :            :     long   lLastRMargin;
     207                 :            :     SvxProtectItem aProtectItem;
     208                 :            :     SfxBoolItem* pTextRTLItem;
     209                 :            :     sal_uInt16 nControlerItems;
     210                 :            :     sal_uInt16 nIdx;
     211                 :            :     sal_uInt16 nColLeftPix, nColRightPix; // Pixel values for left / right edge
     212                 :            :                                       // For columns; buffered to prevent
     213                 :            :                                       // recalculation errors
     214                 :            :                                       // May be has to be widen for future values
     215                 :            :     sal_Bool bIsTableRows : 1;      // pColumnItem contains table rows instead of columns
     216                 :            :     //#i24363# tab stops relative to indent
     217                 :            :     sal_Bool bIsTabsRelativeToIndent : 1; // Tab stops relative to paragraph indent?
     218                 :       2844 :     SvxRuler_Impl() :
     219                 :            :     pPercBuf(0), pBlockBuf(0),
     220                 :            :     nPercSize(0), nTotalDist(0),
     221                 :            :     lOldWinPos(0),
     222                 :            :     lMaxLeftLogic(0), lMaxRightLogic(0),
     223                 :            :     lLastLMargin(0), lLastRMargin(0),
     224                 :            :     aProtectItem(SID_RULER_PROTECT),
     225                 :            :     pTextRTLItem(0), nControlerItems(0),
     226                 :            :     nIdx(0),
     227                 :            :     nColLeftPix(0), nColRightPix(0),
     228                 :            : 
     229                 :            :     bIsTableRows(sal_False),
     230                 :       2844 :     bIsTabsRelativeToIndent(sal_True)
     231                 :            :     {
     232                 :       2844 :     }
     233                 :       2670 :     ~SvxRuler_Impl()
     234                 :       2670 :     {
     235                 :       2670 :         nPercSize = 0; nTotalDist = 0;
     236 [ -  + ][ -  + ]:       2670 :         delete[] pPercBuf; delete[] pBlockBuf; pPercBuf = 0;
     237 [ +  + ][ +  - ]:       2670 :         delete pTextRTLItem;
     238                 :       2670 :     }
     239                 :            :     void SetPercSize(sal_uInt16 nSize);
     240                 :            : 
     241                 :            : };
     242                 :            : 
     243                 :            : 
     244                 :            : 
     245                 :          0 : void SvxRuler_Impl::SetPercSize(sal_uInt16 nSize)
     246                 :            : {
     247         [ #  # ]:          0 :     if(nSize > nPercSize)
     248                 :            :     {
     249         [ #  # ]:          0 :         delete[] pPercBuf;
     250         [ #  # ]:          0 :         delete[] pBlockBuf;
     251                 :          0 :         pPercBuf = new sal_uInt16[nPercSize = nSize];
     252                 :          0 :         pBlockBuf = new sal_uInt16[nPercSize = nSize];
     253                 :            :     }
     254                 :          0 :     size_t nSize2 = sizeof(sal_uInt16) * nPercSize;
     255                 :          0 :     memset(pPercBuf, 0, nSize2);
     256                 :          0 :     memset(pBlockBuf, 0, nSize2);
     257                 :          0 : }
     258                 :            : 
     259                 :            : 
     260                 :            : // Constructor of the ruler
     261                 :            : 
     262                 :            : // SID_ATTR_ULSPACE, SID_ATTR_LRSPACE
     263                 :            : // expects as parameter SvxULSpaceItem for page edge
     264                 :            : // (either left/right or top/bottom)
     265                 :            : // Ruler: SetMargin1, SetMargin2
     266                 :            : 
     267                 :            : // SID_RULER_PAGE_POS
     268                 :            : // expectes as parameter the initial value of the page and page width
     269                 :            : // Ruler: SetPagePos
     270                 :            : 
     271                 :            : // SID_ATTR_TABSTOP
     272                 :            : // expects: SvxTabStopItem
     273                 :            : // Ruler: SetTabs
     274                 :            : 
     275                 :            : // SID_ATTR_PARA_LRSPACE
     276                 :            : // left, right paragraph edge in H-ruler
     277                 :            : // Ruler: SetIndents
     278                 :            : 
     279                 :            : // SID_RULER_BORDERS
     280                 :            : // Table borders, columns
     281                 :            : // expects: something like SwTabCols
     282                 :            : // Ruler: SetBorders
     283                 :            : 
     284                 :            : 
     285                 :       2844 : SvxRuler::SvxRuler
     286                 :            : (
     287                 :            :  Window* pParent,                               // StarView Parent
     288                 :            :  Window* pWin,            // Output window: is used for conversion
     289                 :            :                           // logical units <-> pixels
     290                 :            :  sal_uInt16  flags,       // Display flags, see ruler.hxx
     291                 :            :  SfxBindings &rBindings,  // associated Bindings
     292                 :            :  WinBits nWinStyle                              // StarView WinBits
     293                 :            : )
     294                 :            : : Ruler(pParent, nWinStyle),
     295         [ +  - ]:       2844 :   pCtrlItem(new SvxRulerItem *[CTRL_ITEM_COUNT]),
     296                 :            :   pLRSpaceItem(0),
     297                 :            :   pMinMaxItem(0),
     298                 :            :   pULSpaceItem(0),
     299                 :            :   pTabStopItem(0),
     300                 :            :   pParaItem(0),
     301                 :            :   pParaBorderItem(0),
     302                 :            :   pPagePosItem(0),
     303                 :            :   pColumnItem(0),
     304                 :            :   pObjectItem(0),
     305                 :            :   pEditWin(pWin),
     306         [ +  - ]:       2844 :   pRuler_Imp(new SvxRuler_Impl),
     307                 :            :   bAppSetNullOffset(sal_False),  // Is the 0-offset of the ruler set by the application?
     308                 :            :   lLogicNullOffset(0),
     309                 :            :   lAppNullOffset(LONG_MAX),
     310                 :            :   lMinFrame(5),
     311                 :            :   lInitialDragPos(0),
     312                 :            :   nFlags(flags),
     313                 :            :   nDragType(NONE),
     314                 :            :   nDefTabType(RULER_TAB_LEFT),
     315                 :            :   nTabCount(0),
     316                 :            :   nTabBufSize(0),
     317                 :            :   lDefTabDist(50),
     318                 :            :   lTabPos(-1),
     319                 :            :   pTabs(0),
     320                 :            :   pIndents(0),
     321         [ +  - ]:       2844 :   pBorders(new RulerBorder[1]), // due to one column tables
     322                 :            :   nBorderCount(0),
     323                 :            :   pObjectBorders(0),
     324                 :            :   pBindings(&rBindings),
     325                 :            :   nDragOffset(0),
     326                 :            :   nMaxLeft(0),
     327                 :            :   nMaxRight(0),
     328                 :            :   bValid(sal_False),
     329                 :            :   bListening(sal_False),
     330 [ +  - ][ +  - ]:       5688 :   bActive(sal_True)
     331                 :            : 
     332                 :            : /* [Description]
     333                 :            : 
     334                 :            :    Constructor; Initialize data buffer; controller items are created
     335                 :            : */
     336                 :            : {
     337                 :       2844 :     memset(pCtrlItem, 0, sizeof(SvxRulerItem *) * CTRL_ITEM_COUNT);
     338                 :            : 
     339         [ +  - ]:       2844 :     rBindings.EnterRegistrations();
     340                 :            : 
     341                 :            :     // Create Supported Items
     342                 :       2844 :     sal_uInt16 i = 0;
     343                 :            :     // Page edges
     344                 :            : 
     345 [ +  - ][ +  - ]:       2844 :     pCtrlItem[i++] = new SvxRulerItem(SID_RULER_LR_MIN_MAX, *this, rBindings);
     346         [ +  + ]:       2844 :     if((nWinStyle & WB_VSCROLL) == WB_VSCROLL)
     347                 :            :     {
     348                 :       1422 :         bHorz = sal_False;
     349 [ +  - ][ +  - ]:       1422 :         pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_ULSPACE, *this, rBindings);
     350                 :            :     }
     351                 :            :     else
     352                 :            :     {
     353                 :       1422 :         bHorz = sal_True;
     354 [ +  - ][ +  - ]:       1422 :         pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_LRSPACE, *this, rBindings);
     355                 :            :     }
     356                 :            : 
     357                 :            :     // Page Position
     358 [ +  - ][ +  - ]:       2844 :     pCtrlItem[i++] = new SvxRulerItem(SID_RULER_PAGE_POS, *this, rBindings);
     359                 :            : 
     360         [ +  + ]:       2844 :     if((nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS)
     361                 :            :     {
     362         [ +  + ]:       2740 :         sal_uInt16 nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
     363 [ +  - ][ +  - ]:       2740 :         pCtrlItem[i++] = new SvxRulerItem(nTabStopId, *this, rBindings);
     364         [ +  - ]:       2740 :         SetExtraType(RULER_EXTRA_TAB, nDefTabType);
     365                 :            :     }
     366                 :            : 
     367                 :            : 
     368         [ +  + ]:       2844 :     if(0 != (nFlags & (SVXRULER_SUPPORT_PARAGRAPH_MARGINS |SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL)))
     369                 :            :     {
     370         [ +  + ]:       2740 :         if(bHorz)
     371 [ +  - ][ +  - ]:       1422 :             pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE, *this, rBindings);
     372                 :            :         else
     373 [ +  - ][ +  - ]:       1318 :             pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE_VERTICAL, *this, rBindings);
     374         [ +  - ]:       2740 :         pIndents = new RulerIndent[5+INDENT_GAP];
     375                 :       2740 :         memset(pIndents, 0, sizeof(RulerIndent)*(3+INDENT_GAP));
     376                 :       2740 :         pIndents[0].nStyle = RULER_STYLE_DONTKNOW;
     377                 :       2740 :         pIndents[1].nStyle = RULER_STYLE_DONTKNOW;
     378                 :       2740 :         pIndents[INDENT_FIRST_LINE].nStyle = RULER_INDENT_TOP;
     379                 :       2740 :         pIndents[INDENT_LEFT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
     380                 :       2740 :         pIndents[INDENT_RIGHT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
     381                 :       2740 :         pIndents[INDENT_LEFT_BORDER].nStyle = RULER_INDENT_BORDER;
     382                 :       2740 :         pIndents[INDENT_RIGHT_BORDER].nStyle = RULER_INDENT_BORDER;
     383         [ +  + ]:      21920 :         for(sal_uInt16 nIn = 0; nIn < 7; nIn++)
     384                 :      19180 :             pIndents[nIn].nPos = 0;
     385                 :            :     }
     386                 :            : 
     387         [ +  + ]:       2844 :     if((nFlags & SVXRULER_SUPPORT_BORDERS) ==  SVXRULER_SUPPORT_BORDERS)
     388                 :            :     {
     389 [ +  - ][ +  + ]:       2636 :         pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL, *this, rBindings);
                 [ +  - ]
     390 [ +  - ][ +  + ]:       2636 :         pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL, *this, rBindings);
                 [ +  - ]
     391                 :            :     }
     392                 :            : 
     393 [ +  - ][ +  - ]:       2844 :     pCtrlItem[i++] = new SvxRulerItem(SID_RULER_TEXT_RIGHT_TO_LEFT, *this, rBindings);
     394                 :            : 
     395         [ +  + ]:       2844 :     if((nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT)
     396                 :            :     {
     397 [ +  - ][ +  - ]:        208 :         pCtrlItem[i++] = new SvxRulerItem(SID_RULER_OBJECT, *this, rBindings );
     398         [ +  - ]:        208 :         pObjectBorders = new RulerBorder[OBJECT_BORDER_COUNT];
     399                 :        208 :         size_t nSize = sizeof( RulerBorder ) * OBJECT_BORDER_COUNT;
     400                 :        208 :         memset(pObjectBorders, 0, nSize);
     401         [ +  + ]:       1040 :         for(sal_uInt16 nBorder = 0; nBorder < OBJECT_BORDER_COUNT; ++nBorder)
     402                 :            :         {
     403                 :        832 :             pObjectBorders[nBorder].nPos   = 0;
     404                 :        832 :             pObjectBorders[nBorder].nWidth = 0;
     405                 :        832 :             pObjectBorders[nBorder].nStyle = RULER_BORDER_MOVEABLE;
     406                 :            :         }
     407                 :            :     }
     408                 :            : 
     409 [ +  - ][ +  - ]:       2844 :     pCtrlItem[i++] = new SvxRulerItem( SID_RULER_PROTECT, *this, rBindings );
     410 [ +  - ][ +  - ]:       2844 :     pCtrlItem[i++] = new SvxRulerItem(SID_RULER_BORDER_DISTANCE, *this, rBindings);
     411                 :       2844 :     pRuler_Imp->nControlerItems=i;
     412                 :            : 
     413         [ +  + ]:       2844 :     if((nFlags & SVXRULER_SUPPORT_SET_NULLOFFSET) ==
     414                 :            :        SVXRULER_SUPPORT_SET_NULLOFFSET)
     415         [ +  - ]:        104 :         SetExtraType(RULER_EXTRA_NULLOFFSET, 0);
     416                 :            : 
     417         [ +  - ]:       2844 :     rBindings.LeaveRegistrations();
     418                 :       2844 : }
     419                 :            : 
     420                 :            : 
     421         [ +  - ]:       2670 : SvxRuler::~SvxRuler()
     422                 :            : 
     423                 :            : /* [Description]
     424                 :            : 
     425                 :            :    Destructor ruler; release internal buffer
     426                 :            : */
     427                 :            : {
     428                 :            :     REMOVE_DEBUG_WINDOW
     429         [ +  + ]:       2670 :     if(bListening)
     430         [ +  - ]:        108 :         EndListening(*pBindings);
     431                 :            : 
     432         [ +  - ]:       2670 :     pBindings->EnterRegistrations();
     433                 :            : 
     434 [ +  - ][ +  + ]:      28954 :     for(sal_uInt16 i = 0; i < CTRL_ITEM_COUNT  && pCtrlItem[i]; ++i)
                 [ +  + ]
     435 [ +  - ][ +  - ]:      26284 :         delete pCtrlItem[i];
     436         [ +  - ]:       2670 :     delete[] pCtrlItem;
     437                 :            : 
     438 [ +  + ][ +  - ]:       2670 :     delete pLRSpaceItem;
     439 [ +  + ][ +  - ]:       2670 :     delete pMinMaxItem;
     440 [ +  + ][ +  - ]:       2670 :     delete pULSpaceItem;
     441 [ +  + ][ +  - ]:       2670 :     delete pTabStopItem;
     442 [ +  + ][ +  - ]:       2670 :     delete pParaItem;
     443 [ +  + ][ +  - ]:       2670 :     delete pParaBorderItem;
     444 [ +  + ][ +  - ]:       2670 :     delete pPagePosItem;
     445 [ +  + ][ +  - ]:       2670 :     delete pColumnItem;
     446 [ +  + ][ +  - ]:       2670 :     delete pObjectItem;
     447         [ +  + ]:       2670 :     delete[] pIndents;
     448         [ +  - ]:       2670 :     delete[] pBorders;
     449         [ +  + ]:       2670 :     delete[] pObjectBorders;
     450         [ +  + ]:       2670 :     delete[] pTabs;
     451 [ +  - ][ +  - ]:       2670 :     delete pRuler_Imp;
     452                 :            : 
     453         [ +  - ]:       2670 :     pBindings->LeaveRegistrations();
     454         [ -  + ]:       5132 : }
     455                 :            : 
     456                 :            : /* [Description]
     457                 :            : 
     458                 :            :    Internal conversion routines
     459                 :            : */
     460                 :            : 
     461                 :       8965 : long SvxRuler::ConvertHPosPixel(long nVal) const
     462                 :            : {
     463         [ +  - ]:       8965 :     return pEditWin->LogicToPixel(Size(nVal, 0)).Width();
     464                 :            : }
     465                 :            : 
     466                 :       1894 : long SvxRuler::ConvertVPosPixel(long nVal) const
     467                 :            : {
     468         [ +  - ]:       1894 :     return pEditWin->LogicToPixel(Size(0, nVal)).Height();
     469                 :            : }
     470                 :            : 
     471                 :       2066 : long SvxRuler::ConvertHSizePixel(long nVal) const
     472                 :            : {
     473         [ +  - ]:       2066 :     return pEditWin->LogicToPixel(Size(nVal, 0)).Width();
     474                 :            : }
     475                 :            : 
     476                 :        159 : long SvxRuler::ConvertVSizePixel(long nVal) const
     477                 :            : {
     478         [ +  - ]:        159 :     return pEditWin->LogicToPixel(Size(0, nVal)).Height();
     479                 :            : }
     480                 :            : 
     481                 :         26 : long SvxRuler::ConvertPosPixel(long nVal) const
     482                 :            : {
     483         [ +  + ]:         26 :     return bHorz ? ConvertHPosPixel(nVal): ConvertVPosPixel(nVal);
     484                 :            : }
     485                 :            : 
     486                 :       2225 : long SvxRuler::ConvertSizePixel(long nVal) const
     487                 :            : {
     488         [ +  + ]:       2225 :     return bHorz? ConvertHSizePixel(nVal): ConvertVSizePixel(nVal);
     489                 :            : }
     490                 :            : 
     491                 :            : 
     492                 :          0 : inline long SvxRuler::ConvertHPosLogic(long nVal) const
     493                 :            : {
     494         [ #  # ]:          0 :     return pEditWin->PixelToLogic(Size(nVal, 0)).Width();
     495                 :            : }
     496                 :            : 
     497                 :          0 : inline long SvxRuler::ConvertVPosLogic(long nVal) const
     498                 :            : {
     499         [ #  # ]:          0 :     return pEditWin->PixelToLogic(Size(0, nVal)).Height();
     500                 :            : }
     501                 :            : 
     502                 :          0 : inline long SvxRuler::ConvertHSizeLogic(long nVal) const
     503                 :            : {
     504         [ #  # ]:          0 :     return pEditWin->PixelToLogic(Size(nVal, 0)).Width();
     505                 :            : }
     506                 :            : 
     507                 :          0 : inline long SvxRuler::ConvertVSizeLogic(long nVal) const
     508                 :            : {
     509         [ #  # ]:          0 :     return pEditWin->PixelToLogic(Size(0, nVal)).Height();
     510                 :            : }
     511                 :            : 
     512                 :          0 : inline long SvxRuler::ConvertPosLogic(long nVal) const
     513                 :            : {
     514         [ #  # ]:          0 :     return bHorz? ConvertHPosLogic(nVal): ConvertVPosLogic(nVal);
     515                 :            : }
     516                 :            : 
     517                 :          0 : inline long SvxRuler::ConvertSizeLogic(long nVal) const
     518                 :            : {
     519         [ #  # ]:          0 :     return bHorz? ConvertHSizeLogic(nVal): ConvertVSizeLogic(nVal);
     520                 :            : }
     521                 :            : 
     522                 :          0 : long SvxRuler::PixelHAdjust(long nVal, long nValOld) const
     523                 :            : {
     524         [ #  # ]:          0 :         if(ConvertHSizePixel(nVal)!=ConvertHSizePixel(nValOld))
     525                 :          0 :                 return  nVal;
     526                 :            :         else
     527                 :          0 :                 return  nValOld;
     528                 :            : }
     529                 :            : 
     530                 :          0 : long SvxRuler::PixelVAdjust(long nVal, long nValOld) const
     531                 :            : {
     532         [ #  # ]:          0 :         if(ConvertVSizePixel(nVal)!=ConvertVSizePixel(nValOld))
     533                 :          0 :                 return  nVal;
     534                 :            :         else
     535                 :          0 :                 return  nValOld;
     536                 :            : }
     537                 :            : 
     538                 :          0 : long SvxRuler::PixelAdjust(long nVal, long nValOld) const
     539                 :            : {
     540         [ #  # ]:          0 :         if(ConvertSizePixel(nVal)!=ConvertSizePixel(nValOld))
     541                 :          0 :                 return  nVal;
     542                 :            :         else
     543                 :          0 :                 return  nValOld;
     544                 :            : }
     545                 :            : 
     546                 :            : 
     547                 :          2 : inline sal_uInt16 SvxRuler::GetObjectBordersOff(sal_uInt16 nIdx) const
     548                 :            : {
     549         [ +  + ]:          2 :     return bHorz? nIdx: nIdx + 2;
     550                 :            : }
     551                 :            : 
     552                 :            : 
     553                 :      13134 : void SvxRuler::UpdateFrame()
     554                 :            : 
     555                 :            : /* [Description]
     556                 :            : 
     557                 :            :    Update Upper Left edge.
     558                 :            :    Items are translated into the representation of the ruler.
     559                 :            : */
     560                 :            : 
     561                 :            : {
     562                 :            :     const sal_uInt16 nMarginStyle =
     563                 :      13134 :         ( pRuler_Imp->aProtectItem.IsSizeProtected() ||
     564                 :      12944 :           pRuler_Imp->aProtectItem.IsPosProtected() ) ?
     565   [ +  +  +  - ]:      26078 :         0 : RULER_MARGIN_SIZEABLE;
     566                 :            : 
     567 [ +  + ][ +  - ]:      13134 :     if(pLRSpaceItem && pPagePosItem)
     568                 :            :     {
     569                 :            :         // if no initialization by default app behavior
     570                 :        942 :         const long nOld = lLogicNullOffset;
     571                 :            :         lLogicNullOffset = pColumnItem?
     572         [ +  + ]:        942 :             pColumnItem->GetLeft(): pLRSpaceItem->GetLeft();
     573         [ +  + ]:        942 :         if(bAppSetNullOffset)
     574                 :         99 :             lAppNullOffset += lLogicNullOffset - nOld;
     575 [ +  + ][ -  + ]:        942 :         if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX)
     576                 :            :         {
     577                 :        843 :             Ruler::SetNullOffset(ConvertHPosPixel(lLogicNullOffset));
     578                 :        843 :             SetMargin1( 0, nMarginStyle );
     579                 :        843 :             lAppNullOffset = 0;
     580                 :            :         }
     581                 :            :         else
     582                 :         99 :             SetMargin1( ConvertHPosPixel( lAppNullOffset ), nMarginStyle );
     583                 :        942 :         long lRight = 0;
     584                 :            :             // evaluate the table right edge of the table
     585 [ +  + ][ +  - ]:        942 :         if(pColumnItem && pColumnItem->IsTable())
                 [ +  + ]
     586                 :          2 :             lRight = pColumnItem->GetRight();
     587                 :            :         else
     588                 :        940 :             lRight = pLRSpaceItem->GetRight();
     589                 :            : 
     590                 :            :         sal_uIntPtr aWidth=
     591                 :        942 :             ConvertHPosPixel(pPagePosItem->GetWidth() - lRight -
     592                 :        942 :                                     lLogicNullOffset + lAppNullOffset);
     593                 :        942 :         SetMargin2( aWidth, nMarginStyle );
     594                 :            :     }
     595                 :            :     else
     596 [ +  + ][ +  - ]:      12192 :         if(pULSpaceItem && pPagePosItem)
     597                 :            :         {
     598                 :            :             // relative the upper edge of the surrounding frame
     599                 :        939 :             const long nOld = lLogicNullOffset;
     600                 :            :             lLogicNullOffset = pColumnItem?
     601         [ +  + ]:        939 :                 pColumnItem->GetLeft(): pULSpaceItem->GetUpper();
     602         [ +  + ]:        939 :             if(bAppSetNullOffset)
     603                 :         96 :                 lAppNullOffset += lLogicNullOffset - nOld;
     604 [ +  + ][ -  + ]:        939 :             if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX) {
     605                 :        843 :                 Ruler::SetNullOffset(ConvertVPosPixel(lLogicNullOffset));
     606                 :        843 :                 lAppNullOffset = 0;
     607                 :        843 :                 SetMargin1( 0, nMarginStyle );
     608                 :            :             }
     609                 :            :             else
     610                 :         96 :                 SetMargin1( ConvertVPosPixel( lAppNullOffset ),nMarginStyle );
     611                 :            : 
     612                 :            :             long lLower = pColumnItem ?
     613         [ +  + ]:        939 :                 pColumnItem->GetRight() : pULSpaceItem->GetLower();
     614                 :            : 
     615                 :        939 :             SetMargin2(ConvertVPosPixel(pPagePosItem->GetHeight() - lLower -
     616                 :            :                                         lLogicNullOffset + lAppNullOffset),
     617                 :        939 :                                         nMarginStyle );
     618                 :            :         }
     619                 :            :     else
     620                 :            :     {
     621                 :            :         // turns off the view
     622                 :      11253 :         SetMargin1();
     623                 :      11253 :         SetMargin2();
     624                 :            :     }
     625         [ +  + ]:      13134 :     if(pColumnItem)
     626                 :            :     {
     627                 :          4 :         pRuler_Imp->nColLeftPix = (sal_uInt16) ConvertSizePixel(pColumnItem->GetLeft());
     628                 :          4 :         pRuler_Imp->nColRightPix = (sal_uInt16) ConvertSizePixel(pColumnItem->GetRight());
     629                 :            :     }
     630                 :            : 
     631                 :      13134 : }
     632                 :            : 
     633                 :          0 : void SvxRuler::MouseMove( const MouseEvent& rMEvt )
     634                 :            : {
     635         [ #  # ]:          0 :     if( bActive )
     636                 :            :     {
     637                 :          0 :         pBindings->Update( SID_RULER_LR_MIN_MAX );
     638                 :          0 :         pBindings->Update( SID_ATTR_LONG_ULSPACE );
     639                 :          0 :         pBindings->Update( SID_ATTR_LONG_LRSPACE );
     640                 :          0 :         pBindings->Update( SID_RULER_PAGE_POS );
     641         [ #  # ]:          0 :         pBindings->Update( bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL);
     642         [ #  # ]:          0 :         pBindings->Update( bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL);
     643         [ #  # ]:          0 :         pBindings->Update( bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
     644         [ #  # ]:          0 :         pBindings->Update( bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL);
     645                 :          0 :         pBindings->Update( SID_RULER_OBJECT );
     646                 :          0 :         pBindings->Update( SID_RULER_PROTECT );
     647                 :            :     }
     648                 :          0 :     Ruler::MouseMove( rMEvt );
     649                 :          0 : }
     650                 :       8061 : void SvxRuler::StartListening_Impl()
     651                 :            : {
     652         [ +  + ]:       8061 :     if(!bListening)
     653                 :            :     {
     654                 :       1130 :         bValid = sal_False;
     655                 :       1130 :         StartListening(*pBindings);
     656                 :       1130 :         bListening = sal_True;
     657                 :            :     }
     658                 :       8061 : }
     659                 :            : 
     660                 :        557 : void SvxRuler::UpdateFrame
     661                 :            : (
     662                 :            :  const SvxLongLRSpaceItem *pItem    // new value LRSpace
     663                 :            : )
     664                 :            : 
     665                 :            : /* [Description]
     666                 :            : 
     667                 :            :    Store new value LRSpace; delete old ones if possible
     668                 :            : */
     669                 :            : 
     670                 :            : {
     671         [ +  - ]:        557 :   if(bActive)
     672                 :            :   {
     673         [ +  + ]:        557 :     delete pLRSpaceItem; pLRSpaceItem = 0;
     674         [ +  + ]:        557 :     if(pItem)
     675         [ +  - ]:        554 :         pLRSpaceItem = new SvxLongLRSpaceItem(*pItem);
     676                 :        557 :     StartListening_Impl();
     677                 :            :   }
     678                 :        557 : }
     679                 :            : 
     680                 :            : 
     681                 :       1102 : void SvxRuler::UpdateFrameMinMax
     682                 :            : (
     683                 :            :  const SfxRectangleItem *pItem  // value for MinMax
     684                 :            : )
     685                 :            : 
     686                 :            : /* [Description]
     687                 :            : 
     688                 :            :    Set new value for MinMax; delete old ones if possible
     689                 :            : */
     690                 :            : 
     691                 :            : {
     692         [ +  - ]:       1102 :     if(bActive)
     693                 :            :     {
     694         [ +  + ]:       1102 :         delete pMinMaxItem; pMinMaxItem = 0;
     695         [ +  - ]:       1102 :         if(pItem)
     696         [ +  - ]:       1102 :             pMinMaxItem = new SfxRectangleItem(*pItem);
     697                 :            :     }
     698                 :       1102 : }
     699                 :            : 
     700                 :            : 
     701                 :        555 : void SvxRuler::UpdateFrame
     702                 :            : (
     703                 :            :  const SvxLongULSpaceItem *pItem    // new value
     704                 :            : )
     705                 :            : 
     706                 :            : /* [Description]
     707                 :            : 
     708                 :            :    Update Right/bottom margin
     709                 :            : */
     710                 :            : 
     711                 :            : 
     712                 :            : {
     713 [ +  - ][ +  - ]:        555 :   if(bActive && !bHorz)
     714                 :            :   {
     715         [ +  + ]:        555 :     delete pULSpaceItem; pULSpaceItem = 0;
     716         [ +  + ]:        555 :     if(pItem)
     717         [ +  - ]:        552 :         pULSpaceItem = new SvxLongULSpaceItem(*pItem);
     718                 :        555 :     StartListening_Impl();
     719                 :            :   }
     720                 :        555 : }
     721                 :            : 
     722                 :       1100 : void SvxRuler::Update( const SvxProtectItem* pItem )
     723                 :            : {
     724         [ +  + ]:       1100 :     if( pItem ) pRuler_Imp->aProtectItem = *pItem;
     725                 :       1100 : }
     726                 :            : 
     727                 :       1096 : void SvxRuler::UpdateTextRTL(const SfxBoolItem* pItem)
     728                 :            : {
     729 [ +  - ][ +  + ]:       1096 :   if(bActive && bHorz)
     730                 :            :   {
     731         [ +  + ]:        548 :     delete pRuler_Imp->pTextRTLItem; pRuler_Imp->pTextRTLItem = 0;
     732         [ +  + ]:        548 :     if(pItem)
     733         [ +  - ]:        545 :         pRuler_Imp->pTextRTLItem = new SfxBoolItem(*pItem);
     734 [ +  + ][ -  + ]:        548 :     SetTextRTL(pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue());
     735                 :        548 :     StartListening_Impl();
     736                 :            :   }
     737                 :       1096 : }
     738                 :            : 
     739                 :       1973 : void SvxRuler::Update
     740                 :            : (
     741                 :            :  const SvxColumnItem *pItem,  // new value
     742                 :            :  sal_uInt16 nSID //Slot Id to identify NULL items
     743                 :            : )
     744                 :            : 
     745                 :            : /* [Description]
     746                 :            : 
     747                 :            :    Set new value for column view
     748                 :            : */
     749                 :            : 
     750                 :            : {
     751         [ +  - ]:       1973 :     if(bActive)
     752                 :            :     {
     753         [ +  + ]:       1973 :         if(pItem)
     754                 :            :         {
     755         [ -  + ]:          4 :             delete pColumnItem; pColumnItem = 0;
     756 [ +  - ][ +  + ]:          4 :             pRuler_Imp->bIsTableRows = (pItem->Which() == SID_RULER_ROWS || pItem->Which() == SID_RULER_ROWS_VERTICAL);
     757         [ +  - ]:          4 :             pColumnItem = new SvxColumnItem(*pItem);
     758 [ +  + ][ -  + ]:          4 :             if(!bHorz && !pRuler_Imp->bIsTableRows)
     759                 :          0 :                 pColumnItem->SetWhich(SID_RULER_BORDERS_VERTICAL);
     760                 :            :         }
     761 [ +  + ][ -  + ]:       1969 :         else if(pColumnItem && pColumnItem->Which() == nSID)
                 [ -  + ]
     762                 :            :         //there are two groups of column items table/frame columns and table rows
     763                 :            :         //both can occur in vertical or horizontal mode
     764                 :            :         //the horizontal ruler handles the SID_RULER_BORDERS and SID_RULER_ROWS_VERTICAL
     765                 :            :         //and the vertical handles SID_RULER_BORDERS_VERTICAL and SID_RULER_ROWS
     766                 :            :         //if pColumnItem is already set with one of the ids then a NULL pItem argument
     767                 :            :         //must not delete it
     768                 :            :         {
     769         [ #  # ]:          0 :             delete pColumnItem; pColumnItem = 0;
     770                 :          0 :             pRuler_Imp->bIsTableRows = sal_False;
     771                 :            :         }
     772                 :       1973 :         StartListening_Impl();
     773                 :            :     }
     774                 :       1973 : }
     775                 :            : 
     776                 :            : 
     777                 :      11550 : void SvxRuler::UpdateColumns()
     778                 :            : 
     779                 :            : /* [Description]
     780                 :            : 
     781                 :            :    Update column view
     782                 :            : */
     783                 :            : {
     784 [ +  + ][ +  - ]:      11550 :     if(pColumnItem && pColumnItem->Count() > 1)
                 [ +  + ]
     785                 :            :     {
     786         [ +  - ]:          4 :         if( nBorderCount < pColumnItem->Count())
     787                 :            :         {
     788         [ +  - ]:          4 :             delete[] pBorders;
     789                 :          4 :             nBorderCount = pColumnItem->Count();
     790                 :          4 :             pBorders = new RulerBorder[nBorderCount];
     791                 :            :         }
     792                 :          4 :         sal_uInt16 _nFlags = RULER_BORDER_VARIABLE;
     793                 :            :         sal_Bool bProtectColumns =
     794                 :          4 :             pRuler_Imp->aProtectItem.IsSizeProtected() ||
     795 [ -  + ][ +  - ]:          4 :             pRuler_Imp->aProtectItem.IsPosProtected();
     796         [ +  - ]:          4 :         if( !bProtectColumns )
     797                 :          4 :             _nFlags |= RULER_BORDER_MOVEABLE;
     798         [ +  - ]:          4 :         if( pColumnItem->IsTable() )
     799                 :          4 :             _nFlags |= RULER_BORDER_TABLE;
     800                 :            :         else
     801         [ #  # ]:          0 :             if ( !bProtectColumns )
     802                 :          0 :                 _nFlags |= RULER_BORDER_SIZEABLE;
     803                 :            : 
     804                 :          4 :         sal_uInt16 nBorders = pColumnItem->Count();
     805         [ +  + ]:          4 :         if(!pRuler_Imp->bIsTableRows)
     806                 :          2 :             --nBorders;
     807         [ +  + ]:         10 :         for(sal_uInt16 i = 0; i < nBorders; ++i)
     808                 :            :         {
     809                 :          6 :             pBorders[i].nStyle = _nFlags;
     810         [ +  + ]:          6 :             if(!(*pColumnItem)[i].bVisible)
     811                 :          2 :                 pBorders[i].nStyle |= RULER_STYLE_INVISIBLE;
     812                 :          6 :             pBorders[i].nPos =
     813                 :          6 :                 ConvertPosPixel((*pColumnItem)[i].nEnd + lAppNullOffset);
     814         [ +  + ]:          6 :             if(pColumnItem->Count() == i + 1)
     815                 :            :             {
     816                 :            :                 //with table rows the end of the table is contained in the
     817                 :            :                 //column item but it has no width!
     818                 :          2 :                 pBorders[i].nWidth = 0;
     819                 :            :             }
     820                 :            :             else
     821                 :            :             {
     822                 :          4 :                 pBorders[i].nWidth =
     823                 :          4 :                     ConvertSizePixel((*pColumnItem)[i+1].nStart -
     824                 :          4 :                                  (*pColumnItem)[i].nEnd);
     825                 :            :             }
     826                 :          6 :             pBorders[i].nMinPos =
     827                 :          6 :                 ConvertPosPixel((*pColumnItem)[i].nEndMin + lAppNullOffset);
     828                 :          6 :             pBorders[i].nMaxPos =
     829                 :          6 :                 ConvertPosPixel((*pColumnItem)[i].nEndMax + lAppNullOffset);
     830                 :            :         }
     831                 :          4 :         SetBorders(pColumnItem->Count()-1, pBorders);
     832                 :            :     }
     833                 :            :     else
     834                 :            :     {
     835                 :      11546 :         SetBorders();
     836                 :            :     }
     837                 :      11550 : }
     838                 :            : 
     839                 :            : 
     840                 :       1584 : void SvxRuler::UpdateObject()
     841                 :            : 
     842                 :            : /* [Description]
     843                 :            : 
     844                 :            :    Update view of object representation
     845                 :            : */
     846                 :            : 
     847                 :            : {
     848         [ +  + ]:       1584 :     if(pObjectItem)
     849                 :            :     {
     850                 :            :         DBG_ASSERT(pObjectBorders, "no Buffer");
     851                 :            :         // !! to the page margin
     852         [ +  + ]:          2 :         long nMargin = pLRSpaceItem? pLRSpaceItem->GetLeft(): 0;
     853                 :          2 :         pObjectBorders[0].nPos =
     854                 :          2 :             ConvertPosPixel(pObjectItem->GetStartX() -
     855                 :          2 :                             nMargin + lAppNullOffset);
     856                 :          2 :         pObjectBorders[1].nPos =
     857                 :          2 :             ConvertPosPixel(pObjectItem->GetEndX() - nMargin + lAppNullOffset);
     858         [ +  + ]:          2 :         nMargin = pULSpaceItem? pULSpaceItem->GetUpper(): 0;
     859                 :          2 :         pObjectBorders[2].nPos =
     860                 :          2 :             ConvertPosPixel(pObjectItem->GetStartY() -
     861                 :          2 :                             nMargin + lAppNullOffset);
     862                 :          2 :         pObjectBorders[3].nPos =
     863                 :          2 :             ConvertPosPixel(pObjectItem->GetEndY() - nMargin + lAppNullOffset);
     864                 :            : 
     865                 :          2 :         const sal_uInt16 nOff = GetObjectBordersOff(0);
     866                 :          2 :         SetBorders(2, pObjectBorders + nOff);
     867                 :            :     }
     868                 :            :     else
     869                 :            :     {
     870                 :       1582 :         SetBorders();
     871                 :            :     }
     872                 :       1584 : }
     873                 :            : 
     874                 :            : 
     875                 :      12344 : void SvxRuler::UpdatePara()
     876                 :            : 
     877                 :            : /* [Description]
     878                 :            : 
     879                 :            :    Update the view for paragraph indents:
     880                 :            :    Left margin, first line indent, right margin paragraph update
     881                 :            :    pIndents[0] = Buffer for old intent
     882                 :            :    pIndents[1] = Buffer for old intent
     883                 :            :    pIndents[INDENT_FIRST_LINE] = First line indent
     884                 :            :    pIndents[3] = left margin
     885                 :            :    pIndents[4] = right margin
     886                 :            :    pIndents[5] = left border distance
     887                 :            :    pIndents[6] = right border distance
     888                 :            : 
     889                 :            : */
     890                 :            : 
     891                 :            : {
     892                 :            :     // Dependence on PagePosItem
     893 [ +  + ][ +  - ]:      12344 :     if(pParaItem && pPagePosItem && !pObjectItem)
                 [ +  - ]
     894                 :            :     {
     895 [ +  - ][ -  + ]:        843 :         sal_Bool bRTLText = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
     896                 :            :         // First-line indent is negative to the left paragraph margin
     897                 :        843 :         long nLeftFrameMargin = GetLeftFrameMargin();
     898                 :        843 :         long nRightFrameMargin = GetRightFrameMargin();
     899         [ -  + ]:        843 :         if(bRTLText)
     900                 :          0 :             pIndents[INDENT_FIRST_LINE].nPos =
     901                 :            :                 ConvertHPosPixel(
     902                 :            :                 nRightFrameMargin -
     903                 :          0 :                 pParaItem->GetTxtLeft() -
     904                 :          0 :                 pParaItem->GetTxtFirstLineOfst() + lAppNullOffset );
     905                 :            :         else
     906                 :        843 :             pIndents[INDENT_FIRST_LINE].nPos =
     907                 :            :                 ConvertHPosPixel(
     908                 :            :                     nLeftFrameMargin +
     909                 :        843 :                     pParaItem->GetTxtLeft() +
     910                 :        843 :                     pParaItem->GetTxtFirstLineOfst() +
     911                 :        843 :                     lAppNullOffset);
     912         [ -  + ]:        843 :         if( pParaItem->IsAutoFirst() )
     913                 :          0 :             pIndents[INDENT_FIRST_LINE].nStyle |= RULER_STYLE_INVISIBLE;
     914                 :            :         else
     915                 :        843 :             pIndents[INDENT_FIRST_LINE].nStyle &= ~RULER_STYLE_INVISIBLE;
     916                 :            : 
     917         [ -  + ]:        843 :         if(bRTLText)
     918                 :            :         {
     919                 :            :             // left margin
     920                 :          0 :             pIndents[INDENT_LEFT_MARGIN].nPos =
     921                 :            :                 ConvertHPosPixel(
     922                 :            :                     nRightFrameMargin -
     923                 :          0 :                     pParaItem->GetTxtLeft() + lAppNullOffset);
     924                 :            :             // right margin
     925                 :          0 :             pIndents[INDENT_RIGHT_MARGIN].nPos =
     926                 :            :                 ConvertHPosPixel(
     927                 :            :                     nLeftFrameMargin +
     928                 :          0 :                     pParaItem->GetRight() + lAppNullOffset);
     929                 :            :         }
     930                 :            :         else
     931                 :            :         {
     932                 :            :             // left margin
     933                 :        843 :             pIndents[INDENT_LEFT_MARGIN].nPos =
     934                 :            :                 ConvertHPosPixel(
     935                 :            :                     nLeftFrameMargin +
     936                 :        843 :                     pParaItem->GetTxtLeft() + lAppNullOffset);
     937                 :            :             // right margin, always negative to the right edge of the surrounding frames
     938                 :        843 :             pIndents[INDENT_RIGHT_MARGIN].nPos =
     939                 :            :                 ConvertHPosPixel(
     940                 :            :                     nRightFrameMargin -
     941                 :        843 :                     pParaItem->GetRight() + lAppNullOffset);
     942                 :            :         }
     943         [ +  - ]:        843 :         if(pParaBorderItem)
     944                 :            :         {
     945                 :        843 :             pIndents[INDENT_LEFT_BORDER].nPos =
     946                 :        843 :             ConvertHPosPixel( nLeftFrameMargin + lAppNullOffset);
     947                 :        843 :             pIndents[INDENT_RIGHT_BORDER].nPos =
     948                 :        843 :                 ConvertHPosPixel(nRightFrameMargin - lAppNullOffset);
     949                 :        843 :             pIndents[INDENT_LEFT_BORDER].nStyle = pIndents[INDENT_RIGHT_BORDER].nStyle &= ~RULER_STYLE_INVISIBLE;
     950                 :            :         }
     951                 :            :         else
     952                 :          0 :             pIndents[INDENT_LEFT_BORDER].nStyle = pIndents[INDENT_RIGHT_BORDER].nStyle |= RULER_STYLE_INVISIBLE;
     953                 :            : 
     954                 :        843 :         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
     955                 :            :     }
     956                 :            :     else
     957                 :            :     {
     958         [ +  - ]:      11501 :         if(pIndents)
     959                 :            :         {
     960                 :      11501 :             pIndents[INDENT_FIRST_LINE].nPos =
     961                 :      11501 :             pIndents[INDENT_LEFT_MARGIN].nPos =
     962                 :      11501 :             pIndents[INDENT_RIGHT_MARGIN].nPos = 0;
     963                 :            :         }
     964                 :      11501 :         SetIndents();        // turn off
     965                 :            :     }
     966                 :      12344 : }
     967                 :            : 
     968                 :            : 
     969                 :       1042 : void SvxRuler::UpdatePara
     970                 :            : (
     971                 :            :  const SvxLRSpaceItem *pItem    // new value of paragraph indents
     972                 :            : )
     973                 :            : 
     974                 :            : /* [Description]
     975                 :            : 
     976                 :            :    Store new value of paragraph indents
     977                 :            : */
     978                 :            : 
     979                 :            : {
     980         [ +  - ]:       1042 :     if(bActive)
     981                 :            :     {
     982         [ +  + ]:       1042 :         delete pParaItem; pParaItem = 0;
     983         [ +  + ]:       1042 :         if(pItem)
     984         [ +  - ]:        492 :             pParaItem = new SvxLRSpaceItem(*pItem);
     985                 :       1042 :         StartListening_Impl();
     986                 :            :     }
     987                 :       1042 : }
     988                 :       1096 : void SvxRuler::UpdateParaBorder(const SvxLRSpaceItem * pItem )
     989                 :            : 
     990                 :            : /* [Description]
     991                 :            : 
     992                 :            :    Border distance
     993                 :            : */
     994                 :            : 
     995                 :            : {
     996         [ +  - ]:       1096 :     if(bActive)
     997                 :            :     {
     998         [ -  + ]:       1096 :         delete pParaBorderItem; pParaBorderItem = 0;
     999         [ +  + ]:       1096 :         if(pItem)
    1000         [ +  - ]:        982 :             pParaBorderItem = new SvxLRSpaceItem(*pItem);
    1001                 :       1096 :         StartListening_Impl();
    1002                 :            :     }
    1003                 :       1096 : }
    1004                 :            : 
    1005                 :            : 
    1006                 :      13134 : void SvxRuler::UpdatePage()
    1007                 :            : 
    1008                 :            : /* [Description]
    1009                 :            : 
    1010                 :            :    Update view of position and width of page
    1011                 :            : */
    1012                 :            : 
    1013                 :            : {
    1014         [ +  + ]:      13134 :     if(pPagePosItem)
    1015                 :            :     {
    1016                 :            :         // all objects are automatically adjusted
    1017         [ +  + ]:       1885 :         if(bHorz)
    1018                 :            :             SetPagePos(
    1019         [ +  - ]:        944 :                 pEditWin->LogicToPixel(pPagePosItem->GetPos()).X(),
    1020                 :       1888 :                 pEditWin->LogicToPixel(Size(pPagePosItem->GetWidth(),0)).
    1021 [ +  - ][ +  - ]:       1888 :                 Width());
    1022                 :            :         else
    1023                 :            :             SetPagePos(
    1024         [ +  - ]:        941 :                 pEditWin->LogicToPixel(pPagePosItem->GetPos()).Y(),
    1025                 :       1882 :                 pEditWin->LogicToPixel(Size(0, pPagePosItem->GetHeight())).
    1026 [ +  - ][ +  - ]:       1882 :                 Height());
    1027         [ +  + ]:       1885 :         if(bAppSetNullOffset)
    1028 [ +  - ][ +  - ]:        195 :             SetNullOffset(ConvertSizePixel(-lAppNullOffset + lLogicNullOffset));
    1029                 :            :     }
    1030                 :            :     else
    1031         [ +  - ]:      11249 :         SetPagePos();
    1032                 :            : 
    1033                 :      13134 :     long lPos = 0;
    1034         [ +  - ]:      13134 :     Point aOwnPos = GetPosPixel();
    1035         [ +  - ]:      13134 :     Point aEdtWinPos = pEditWin->GetPosPixel();
    1036 [ +  - ][ +  - ]:      13134 :     if( Application::GetSettings().GetLayoutRTL() && bHorz )
         [ -  + ][ #  # ]
                 [ -  + ]
    1037                 :            :     {
    1038                 :            :         //#i73321# in RTL the window and the ruler is not mirrored but the
    1039                 :            :         // influence of the vertical ruler is inverted
    1040         [ #  # ]:          0 :         Size aOwnSize = GetSizePixel();
    1041         [ #  # ]:          0 :         Size aEdtWinSize = pEditWin->GetSizePixel();
    1042                 :          0 :         lPos = aOwnSize.Width() - aEdtWinSize.Width();
    1043                 :          0 :         lPos -= (aEdtWinPos - aOwnPos).X();
    1044                 :            :     }
    1045                 :            :     else
    1046                 :            :     {
    1047                 :      13134 :         Point aPos(aEdtWinPos - aOwnPos);
    1048         [ +  + ]:      13134 :         lPos= bHorz ? aPos.X() : aPos.Y();
    1049                 :            :     }
    1050                 :            : 
    1051                 :            : // Unfortunately, we get the offset of the edit window to the ruler never
    1052                 :            : // through a status message. So we set it ourselves if necessary.
    1053         [ +  + ]:      13134 :     if(lPos!=pRuler_Imp->lOldWinPos)
    1054                 :            :     {
    1055                 :       1396 :         pRuler_Imp->lOldWinPos=lPos;
    1056         [ +  - ]:       1396 :         SetWinPos(lPos);
    1057                 :            :     }
    1058                 :      13134 : }
    1059                 :            : 
    1060                 :            : 
    1061                 :       1138 : void SvxRuler::Update
    1062                 :            : (
    1063                 :            :  const SvxPagePosSizeItem *pItem // new value of page attributes
    1064                 :            : )
    1065                 :            : 
    1066                 :            : /* [Description]
    1067                 :            : 
    1068                 :            :    Store new value of page attributes
    1069                 :            : */
    1070                 :            : 
    1071                 :            : {
    1072         [ +  - ]:       1138 :     if(bActive)
    1073                 :            :     {
    1074         [ +  + ]:       1138 :         delete pPagePosItem; pPagePosItem = 0;
    1075         [ +  - ]:       1138 :         if(pItem)
    1076         [ +  - ]:       1138 :             pPagePosItem = new SvxPagePosSizeItem(*pItem);
    1077                 :       1138 :         StartListening_Impl();
    1078                 :            :     }
    1079                 :       1138 : }
    1080                 :            : 
    1081                 :            : 
    1082                 :            : //
    1083                 :            : 
    1084                 :       1444 : void SvxRuler::SetDefTabDist
    1085                 :            : (
    1086                 :            :  long l  // New distance for DefaultTabs in App-Metrics
    1087                 :            : )
    1088                 :            : 
    1089                 :            : /* [Description]
    1090                 :            : 
    1091                 :            :    New distance is set for DefaultTabs
    1092                 :            : */
    1093                 :            : 
    1094                 :            : {
    1095                 :            : 
    1096                 :       1444 :     lDefTabDist = l;
    1097                 :       1444 :     UpdateTabs();
    1098                 :       1444 : }
    1099                 :            : 
    1100                 :            : 
    1101                 :          0 : sal_uInt16 ToSvTab_Impl(SvxTabAdjust eAdj)
    1102                 :            : 
    1103                 :            : /* [Description]
    1104                 :            : 
    1105                 :            :    Internal convertion routine between SV-Tab.-Enum and Svx
    1106                 :            : */
    1107                 :            : 
    1108                 :            : {
    1109   [ #  #  #  #  :          0 :     switch(eAdj) {
                   #  # ]
    1110                 :          0 :     case SVX_TAB_ADJUST_LEFT:    return RULER_TAB_LEFT;
    1111                 :          0 :     case SVX_TAB_ADJUST_RIGHT:   return RULER_TAB_RIGHT;
    1112                 :          0 :     case SVX_TAB_ADJUST_DECIMAL: return RULER_TAB_DECIMAL;
    1113                 :          0 :     case SVX_TAB_ADJUST_CENTER:  return RULER_TAB_CENTER;
    1114                 :          0 :     case SVX_TAB_ADJUST_DEFAULT: return RULER_TAB_DEFAULT;
    1115                 :            :     default: ;//prevent warning
    1116                 :            :     }
    1117                 :          0 :     return 0;
    1118                 :            : }
    1119                 :            : 
    1120                 :            : 
    1121                 :          0 : SvxTabAdjust ToAttrTab_Impl(sal_uInt16 eAdj)
    1122                 :            : {
    1123   [ #  #  #  #  :          0 :     switch(eAdj) {
                   #  # ]
    1124                 :          0 :     case RULER_TAB_LEFT:    return SVX_TAB_ADJUST_LEFT    ;
    1125                 :          0 :     case RULER_TAB_RIGHT:   return SVX_TAB_ADJUST_RIGHT   ;
    1126                 :          0 :     case RULER_TAB_DECIMAL: return SVX_TAB_ADJUST_DECIMAL ;
    1127                 :          0 :     case RULER_TAB_CENTER:  return SVX_TAB_ADJUST_CENTER  ;
    1128                 :          0 :     case RULER_TAB_DEFAULT: return SVX_TAB_ADJUST_DEFAULT ;
    1129                 :            :     }
    1130                 :          0 :     return SVX_TAB_ADJUST_LEFT;
    1131                 :            : }
    1132                 :            : 
    1133                 :            : 
    1134                 :      13788 : void SvxRuler::UpdateTabs()
    1135                 :            : 
    1136                 :            : /* [Description]
    1137                 :            : 
    1138                 :            :    Update of Tabs
    1139                 :            : */
    1140                 :            : 
    1141                 :            : {
    1142         [ -  + ]:      13788 :     if(IsDrag())
    1143                 :      13788 :         return;
    1144 [ +  + ][ +  + ]:      13788 :     if(pPagePosItem && pParaItem && pTabStopItem && !pObjectItem)
         [ +  + ][ +  - ]
    1145                 :            :     {
    1146                 :            :         // buffer for DefaultTabStop
    1147                 :            :         // Distance last Tab <-> Right paragraph margin / DefaultTabDist
    1148 [ +  - ][ -  + ]:        952 :         sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
    1149                 :        952 :         long nLeftFrameMargin = GetLeftFrameMargin();
    1150                 :        952 :         long nRightFrameMargin = GetRightFrameMargin();
    1151                 :            : 
    1152                 :            :     //#i24363# tab stops relative to indent
    1153                 :        952 :         const long nParaItemTxtLeft = pParaItem->GetTxtLeft();
    1154                 :            : 
    1155                 :        952 :         const long lParaIndent = nLeftFrameMargin + nParaItemTxtLeft;
    1156                 :            : 
    1157                 :            :         const long lLastTab =
    1158                 :        952 :              pTabStopItem->Count()?
    1159         [ -  + ]:        952 :               ConvertHPosPixel((*pTabStopItem)[pTabStopItem->Count()-1].GetTabPos()): 0;
    1160                 :            :         const long lPosPixel =
    1161                 :        952 :             ConvertHPosPixel(lParaIndent) + lLastTab;
    1162                 :            :         const long lRightIndent =
    1163                 :        952 :             ConvertHPosPixel(nRightFrameMargin - pParaItem->GetRight());
    1164                 :        952 :         long nDefTabDist = ConvertHPosPixel(lDefTabDist);
    1165         [ -  + ]:        952 :         if( !nDefTabDist )
    1166                 :          0 :             nDefTabDist = 1;
    1167                 :            :         const sal_uInt16 nDefTabBuf = lPosPixel > lRightIndent ||
    1168                 :            :             lLastTab > lRightIndent
    1169                 :            :                 ? 0
    1170 [ +  - ][ +  - ]:        952 :                 : (sal_uInt16)( (lRightIndent - lPosPixel) / nDefTabDist );
    1171                 :            : 
    1172         [ +  + ]:        952 :         if(pTabStopItem->Count() + TAB_GAP + nDefTabBuf > nTabBufSize)
    1173                 :            :         {
    1174         [ -  + ]:        442 :             delete[] pTabs;
    1175                 :            :             // 10 (GAP) in stock
    1176                 :        442 :             nTabBufSize = pTabStopItem->Count() + TAB_GAP + nDefTabBuf + GAP;
    1177                 :        442 :             pTabs = new RulerTab[nTabBufSize];
    1178                 :            :         }
    1179                 :            : 
    1180                 :        952 :         nTabCount = 0;
    1181                 :            :         sal_uInt16 j;
    1182                 :            :         //#i24363# tab stops relative to indent
    1183                 :        952 :         const long lRightPixMargin = ConvertSizePixel(nRightFrameMargin - nParaItemTxtLeft );
    1184                 :        952 :         const long lParaIndentPix = ConvertSizePixel(lParaIndent);
    1185         [ -  + ]:        952 :         for(j = 0; j < pTabStopItem->Count(); ++j)
    1186                 :            :         {
    1187                 :          0 :             const SvxTabStop *pTab = &(*pTabStopItem)[j];
    1188                 :          0 :             pTabs[nTabCount+TAB_GAP].nPos =
    1189                 :            :                 ConvertHPosPixel(
    1190         [ #  # ]:          0 :                 (pRuler_Imp->bIsTabsRelativeToIndent ? lParaIndent : 0 ) + pTab->GetTabPos() + lAppNullOffset);
    1191         [ #  # ]:          0 :             if(bRTL)
    1192                 :            :             {
    1193                 :          0 :                 pTabs[nTabCount+TAB_GAP].nPos = lParaIndentPix + lRightPixMargin - pTabs[nTabCount+TAB_GAP].nPos;
    1194                 :            :             }
    1195                 :          0 :             pTabs[nTabCount+TAB_GAP].nStyle = ToSvTab_Impl(pTab->GetAdjustment());
    1196                 :          0 :             ++nTabCount;
    1197                 :            :         }
    1198         [ +  - ]:        952 :         if(!pTabStopItem->Count())
    1199         [ -  + ]:        952 :             pTabs[0].nPos = bRTL ? lRightPixMargin : lParaIndentPix;
    1200                 :            : 
    1201                 :            :         // fill the rest with default Tabs
    1202         [ -  + ]:        952 :         if(bRTL)
    1203                 :            :         {
    1204         [ #  # ]:          0 :             for(j = 0; j < nDefTabBuf; ++j)
    1205                 :            :             {
    1206                 :          0 :                 pTabs[nTabCount + TAB_GAP].nPos =
    1207                 :          0 :                     pTabs[nTabCount].nPos - nDefTabDist;
    1208                 :            : 
    1209         [ #  # ]:          0 :                 if(j == 0 )
    1210                 :            :                     pTabs[nTabCount + TAB_GAP].nPos -=
    1211                 :          0 :                         ((pTabs[nTabCount + TAB_GAP].nPos - lRightPixMargin)
    1212                 :          0 :                          % nDefTabDist );
    1213         [ #  # ]:          0 :                 if(pTabs[nTabCount+TAB_GAP].nPos <= lParaIndentPix)
    1214                 :          0 :                     break;
    1215                 :          0 :                 pTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
    1216                 :          0 :                 ++nTabCount;
    1217                 :            :             }
    1218                 :            :         }
    1219                 :            :         else
    1220                 :            :         {
    1221         [ +  + ]:      13527 :             for(j = 0; j < nDefTabBuf; ++j)
    1222                 :            :             {
    1223         [ +  + ]:      12593 :                 if( j == 0 )
    1224                 :            :                 {
    1225                 :            :                     //set the first default tab stop
    1226         [ +  + ]:        952 :                     if(pRuler_Imp->bIsTabsRelativeToIndent)
    1227                 :            :                     {
    1228                 :        931 :                         pTabs[nTabCount + TAB_GAP].nPos =
    1229                 :        931 :                             (pTabs[nTabCount].nPos + nDefTabDist);
    1230                 :            :                         pTabs[nTabCount + TAB_GAP].nPos -=
    1231                 :        931 :                             ((pTabs[nTabCount + TAB_GAP].nPos - lParaIndentPix)
    1232                 :        931 :                                 % nDefTabDist );
    1233                 :            :                     }
    1234                 :            :                     else
    1235                 :            :                     {
    1236         [ -  + ]:         21 :                         if( pTabs[nTabCount].nPos < 0 )
    1237                 :            :                         {
    1238                 :          0 :                             pTabs[nTabCount + TAB_GAP].nPos = ( pTabs[nTabCount].nPos / nDefTabDist ) * nDefTabDist;
    1239                 :            :                         }
    1240                 :            :                         else
    1241                 :            :                         {
    1242                 :         21 :                             pTabs[nTabCount + TAB_GAP].nPos = ( pTabs[nTabCount].nPos / nDefTabDist + 1 ) * nDefTabDist;
    1243                 :            :                         }
    1244                 :            :                     }
    1245                 :            : 
    1246                 :            :                 }
    1247                 :            :                 else
    1248                 :            :                 {
    1249                 :            :                     //simply add the default distance to the last position
    1250                 :      11641 :                     pTabs[nTabCount + TAB_GAP].nPos =
    1251                 :      11641 :                     pTabs[nTabCount].nPos + nDefTabDist;
    1252                 :            :                 }
    1253                 :            : 
    1254         [ +  + ]:      12593 :                 if(pTabs[nTabCount+TAB_GAP].nPos >= lRightIndent)
    1255                 :         18 :                     break;
    1256                 :      12575 :                 pTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
    1257                 :      12575 :                 ++nTabCount;
    1258                 :            :             }
    1259                 :            :         }
    1260                 :        952 :         SetTabs(nTabCount, pTabs+TAB_GAP);
    1261                 :        952 :         DBG_ASSERT(nTabCount + TAB_GAP <= nTabBufSize, "BufferSize too small");
    1262                 :            :     }
    1263                 :            :     else
    1264                 :            :     {
    1265                 :      12836 :         SetTabs();
    1266                 :            :     }
    1267                 :            : }
    1268                 :            : 
    1269                 :            : 
    1270                 :       1042 : void SvxRuler::Update
    1271                 :            : (
    1272                 :            :  const SvxTabStopItem *pItem    // new value for tabs
    1273                 :            : )
    1274                 :            : 
    1275                 :            : /* [Description]
    1276                 :            : 
    1277                 :            :    Store new value for tabs; delete old ones if possible
    1278                 :            : */
    1279                 :            : 
    1280                 :            : {
    1281         [ +  - ]:       1042 :     if(bActive)
    1282                 :            :     {
    1283         [ -  + ]:       1042 :         delete pTabStopItem; pTabStopItem = 0;
    1284         [ +  + ]:       1042 :         if(pItem)
    1285                 :            :         {
    1286         [ +  - ]:        489 :             pTabStopItem = new SvxTabStopItem(*pItem);
    1287         [ -  + ]:        489 :             if(!bHorz)
    1288                 :          0 :                 pTabStopItem->SetWhich(SID_ATTR_TABSTOP_VERTICAL);
    1289                 :            :         }
    1290                 :       1042 :         StartListening_Impl();
    1291                 :            :     }
    1292                 :       1042 : }
    1293                 :            : 
    1294                 :            : 
    1295                 :        110 : void SvxRuler::Update
    1296                 :            : (
    1297                 :            :  const SvxObjectItem *pItem             // new value for objects
    1298                 :            : )
    1299                 :            : 
    1300                 :            : /* [Description]
    1301                 :            : 
    1302                 :            :    Store new value for objects
    1303                 :            : */
    1304                 :            : 
    1305                 :            : {
    1306         [ +  - ]:        110 :     if(bActive)
    1307                 :            :     {
    1308         [ -  + ]:        110 :         delete pObjectItem; pObjectItem = 0;
    1309         [ +  + ]:        110 :         if(pItem)
    1310         [ +  - ]:          2 :             pObjectItem = new SvxObjectItem(*pItem);
    1311                 :        110 :         StartListening_Impl();
    1312                 :            :     }
    1313                 :        110 : }
    1314                 :            : 
    1315                 :            : 
    1316                 :        114 : void SvxRuler::SetNullOffsetLogic
    1317                 :            : (
    1318                 :            :  long lVal  // Setting of the logic NullOffsets
    1319                 :            : )
    1320                 :            : {
    1321                 :        114 :     lAppNullOffset = lLogicNullOffset - lVal;
    1322                 :        114 :     bAppSetNullOffset = sal_True;
    1323                 :        114 :     Ruler::SetNullOffset(ConvertSizePixel(lVal));
    1324                 :        114 :     Update();
    1325                 :        114 : }
    1326                 :            : 
    1327                 :            : 
    1328                 :      13134 : void SvxRuler::Update()
    1329                 :            : 
    1330                 :            : /* [Description]
    1331                 :            : 
    1332                 :            :    Perform update of view
    1333                 :            : */
    1334                 :            : 
    1335                 :            : {
    1336         [ -  + ]:      13134 :     if(IsDrag())
    1337                 :      13134 :         return;
    1338                 :      13134 :     UpdatePage();
    1339                 :      13134 :     UpdateFrame();
    1340         [ +  + ]:      13134 :     if((nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT)
    1341                 :       1584 :         UpdateObject();
    1342                 :            :     else
    1343                 :      11550 :         UpdateColumns();
    1344                 :            : 
    1345         [ +  + ]:      13134 :     if(0 != (nFlags & (SVXRULER_SUPPORT_PARAGRAPH_MARGINS |SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL)))
    1346                 :      12344 :       UpdatePara();
    1347         [ +  + ]:      13134 :     if(0 != (nFlags & SVXRULER_SUPPORT_TABS))
    1348                 :      12344 :       UpdateTabs();
    1349                 :            : }
    1350                 :            : 
    1351                 :            : 
    1352                 :          0 : inline long SvxRuler::GetPageWidth() const
    1353                 :            : {
    1354         [ #  # ]:          0 :     return bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
    1355                 :            : 
    1356                 :            : }
    1357                 :            : 
    1358                 :            : 
    1359                 :          0 : inline long SvxRuler::GetFrameLeft() const
    1360                 :            : 
    1361                 :            : /* [Description]
    1362                 :            : 
    1363                 :            :    Get Left margin in Pixels
    1364                 :            : */
    1365                 :            : 
    1366                 :            : 
    1367                 :            : {
    1368                 :            :     return  bAppSetNullOffset?
    1369                 :          0 :             GetMargin1() + ConvertSizePixel(lLogicNullOffset):
    1370         [ #  # ]:          0 :             Ruler::GetNullOffset();
    1371                 :            : }
    1372                 :            : 
    1373                 :            : inline void SvxRuler::SetFrameLeft(long l)
    1374                 :            : 
    1375                 :            : /* [Description]
    1376                 :            : 
    1377                 :            :    Set Left margin in Pixels
    1378                 :            : */
    1379                 :            : 
    1380                 :            : {
    1381                 :            :     sal_Bool bProtectColumns =
    1382                 :            :         pRuler_Imp->aProtectItem.IsSizeProtected() ||
    1383                 :            :         pRuler_Imp->aProtectItem.IsPosProtected();
    1384                 :            :     if(bAppSetNullOffset)
    1385                 :            :         SetMargin1(l - ConvertSizePixel(lLogicNullOffset),
    1386                 :            :                    bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE);
    1387                 :            :     else
    1388                 :            :         Ruler::SetNullOffset(l);
    1389                 :            : }
    1390                 :            : 
    1391                 :            : 
    1392                 :          0 : long SvxRuler::GetFirstLineIndent() const
    1393                 :            : 
    1394                 :            : /* [Description]
    1395                 :            : 
    1396                 :            :    Get First-line indent in pixels
    1397                 :            : */
    1398                 :            : 
    1399                 :            : {
    1400         [ #  # ]:          0 :     return pParaItem? pIndents[INDENT_FIRST_LINE].nPos: GetMargin1();
    1401                 :            : }
    1402                 :            : 
    1403                 :            : 
    1404                 :          0 : long SvxRuler::GetLeftIndent() const
    1405                 :            : 
    1406                 :            : /* [Description]
    1407                 :            : 
    1408                 :            :    Get Left paragraph margin in Pixels
    1409                 :            : */
    1410                 :            : 
    1411                 :            : {
    1412         [ #  # ]:          0 :     return pParaItem? pIndents[INDENT_LEFT_MARGIN].nPos: GetMargin1();
    1413                 :            : }
    1414                 :            : 
    1415                 :            : 
    1416                 :            : 
    1417                 :          0 : long SvxRuler::GetRightIndent() const
    1418                 :            : 
    1419                 :            : /* [Description]
    1420                 :            : 
    1421                 :            :    Get Right paragraph margin in Pixels
    1422                 :            : */
    1423                 :            : 
    1424                 :            : {
    1425         [ #  # ]:          0 :     return pParaItem? pIndents[INDENT_RIGHT_MARGIN].nPos: GetMargin2();
    1426                 :            : }
    1427                 :            : 
    1428                 :            : 
    1429                 :          0 : long SvxRuler::GetLogicRightIndent() const
    1430                 :            : 
    1431                 :            : /* [Description]
    1432                 :            : 
    1433                 :            :    Get Right paragraph margin in Logic
    1434                 :            : */
    1435                 :            : 
    1436                 :            : {
    1437         [ #  # ]:          0 :     return pParaItem ? GetRightFrameMargin()-pParaItem->GetRight() : GetRightFrameMargin();
    1438                 :            : }
    1439                 :            : 
    1440                 :            : // Left margin in App values, is either the margin (= 0)  or the left edge of
    1441                 :            : // the column that is set in the column attribute as current column.
    1442                 :       1795 : long SvxRuler::GetLeftFrameMargin() const
    1443                 :            : {
    1444                 :            :     // #126721# for some unknown reason the current column is set to 0xffff
    1445                 :            :     DBG_ASSERT(!pColumnItem || pColumnItem->GetActColumn() < pColumnItem->Count(),
    1446                 :            :                     "issue #126721# - invalid current column!");
    1447                 :            :     long nLeft =
    1448                 :         14 :         pColumnItem && pColumnItem->Count() && pColumnItem->GetActColumn() < pColumnItem->Count() ?
    1449   [ +  +  +  -  :       1809 :         (*pColumnItem)[pColumnItem->GetActColumn()].nStart : 0;
                   +  - ]
    1450 [ +  - ][ +  + ]:       1795 :     if(pParaBorderItem && (!pColumnItem || pColumnItem->IsTable()))
         [ +  - ][ +  - ]
    1451                 :       1795 :         nLeft += pParaBorderItem->GetLeft();
    1452                 :       1795 :     return nLeft;
    1453                 :            : }
    1454                 :            : 
    1455                 :          0 : inline long SvxRuler::GetLeftMin() const
    1456                 :            : {
    1457                 :            :     DBG_ASSERT(pMinMaxItem, "no MinMax value set");
    1458                 :            :     return pMinMaxItem?
    1459                 :          0 :         bHorz?  pMinMaxItem->GetValue().Left(): pMinMaxItem->GetValue().Top()
    1460 [ #  # ][ #  # ]:          0 :                 : 0;
    1461                 :            : }
    1462                 :            : 
    1463                 :          0 : inline long SvxRuler::GetRightMax() const
    1464                 :            : {
    1465                 :            :     DBG_ASSERT(pMinMaxItem, "no MinMax value set");
    1466                 :            :     return pMinMaxItem?
    1467                 :          0 :         bHorz? pMinMaxItem->GetValue().Right(): pMinMaxItem->GetValue().Bottom()
    1468 [ #  # ][ #  # ]:          0 :             : 0;
    1469                 :            : }
    1470                 :            : 
    1471                 :            : 
    1472                 :       1795 : long SvxRuler::GetRightFrameMargin() const
    1473                 :            : 
    1474                 :            : /* [Description]
    1475                 :            : 
    1476                 :            :    Get right frame margin (in logical units)
    1477                 :            : */
    1478                 :            : 
    1479                 :            : {
    1480         [ +  + ]:       1795 :     if(pColumnItem)
    1481                 :            :     {
    1482         [ +  - ]:          7 :         if(!IsActLastColumn( sal_True ))
    1483                 :            :         {
    1484                 :          7 :             long nRet = (*pColumnItem)[GetActRightColumn( sal_True )].nEnd;
    1485 [ +  - ][ +  - ]:          7 :             if(pColumnItem->IsTable() && pParaBorderItem)
                 [ +  - ]
    1486                 :          7 :                 nRet -= pParaBorderItem->GetRight();
    1487                 :          7 :             return nRet;
    1488                 :            :         }
    1489                 :            :     }
    1490                 :            : 
    1491                 :       1788 :     long l = lLogicNullOffset;
    1492                 :            : 
    1493                 :            :     // If possible deduct right table entry
    1494 [ -  + ][ #  # ]:       1788 :     if(pColumnItem && pColumnItem->IsTable())
                 [ -  + ]
    1495                 :          0 :         l += pColumnItem->GetRight();
    1496 [ +  - ][ +  - ]:       1788 :     else if(bHorz && pLRSpaceItem)
    1497                 :       1788 :         l += pLRSpaceItem->GetRight();
    1498 [ #  # ][ #  # ]:          0 :     else if(!bHorz && pULSpaceItem)
    1499                 :          0 :         l += pULSpaceItem->GetLower();
    1500                 :            : 
    1501 [ +  - ][ -  +  :       1788 :     if(pParaBorderItem &&
             #  #  #  # ]
                 [ +  - ]
    1502                 :          0 :         (!pColumnItem || pColumnItem->IsTable()||IsActLastColumn( sal_True )))
    1503                 :       1788 :         l += pParaBorderItem->GetRight();
    1504                 :            : 
    1505         [ +  - ]:       1788 :     if(bHorz)
    1506                 :       1788 :         l = pPagePosItem->GetWidth() - l;
    1507                 :            :     else
    1508                 :          0 :         l = pPagePosItem->GetHeight() - l;
    1509                 :       1795 :     return l;
    1510                 :            : }
    1511                 :            : 
    1512                 :            : #define NEG_FLAG ( (nFlags & SVXRULER_SUPPORT_NEGATIVE_MARGINS) == \
    1513                 :            :                    SVXRULER_SUPPORT_NEGATIVE_MARGINS )
    1514                 :            : #define TAB_FLAG ( pColumnItem && pColumnItem->IsTable() )
    1515                 :            : 
    1516                 :          0 : long SvxRuler::GetCorrectedDragPos( sal_Bool bLeft, sal_Bool bRight )
    1517                 :            : 
    1518                 :            : /* [Description]
    1519                 :            : 
    1520                 :            :    Corrects the position within the calculated limits. The limit values are in
    1521                 :            :    pixels relative to the page edge.
    1522                 :            : */
    1523                 :            : 
    1524                 :            : {
    1525                 :          0 :     const long lNullPix = Ruler::GetNullOffset();
    1526                 :          0 :     long lDragPos = GetDragPos() + lNullPix;
    1527                 :            : ADD_DEBUG_TEXT("lDragPos: ", String::CreateFromInt32(lDragPos))
    1528 [ #  # ][ #  # ]:          0 :      sal_Bool bHoriRows = bHorz && pRuler_Imp->bIsTableRows;
    1529 [ #  # ][ #  # ]:          0 :     if((bLeft || (bHoriRows)) && lDragPos < nMaxLeft)
                 [ #  # ]
    1530                 :          0 :         lDragPos = nMaxLeft;
    1531 [ #  # ][ #  # ]:          0 :     else if((bRight||bHoriRows) && lDragPos > nMaxRight)
                 [ #  # ]
    1532                 :          0 :         lDragPos = nMaxRight;
    1533                 :          0 :     return lDragPos - lNullPix;
    1534                 :            : }
    1535                 :            : 
    1536                 :            : 
    1537                 :            : 
    1538                 :          0 : void ModifyTabs_Impl
    1539                 :            : (
    1540                 :            :  sal_uInt16 nCount,                             // Number of Tabs
    1541                 :            :  RulerTab *pTabs,                               // Tab buffer
    1542                 :            :  long lDiff                                     // difference to be added
    1543                 :            :  )
    1544                 :            : 
    1545                 :            : /* [Description]
    1546                 :            : 
    1547                 :            :    Helper function, move all the tabs by a fixed value
    1548                 :            : */
    1549                 :            : {
    1550         [ #  # ]:          0 :     if( pTabs )
    1551         [ #  # ]:          0 :         for(sal_uInt16 i = 0; i < nCount; ++i)  pTabs[i].nPos += lDiff;
    1552                 :          0 : }
    1553                 :            : 
    1554                 :            : 
    1555                 :            : 
    1556                 :          0 : void SvxRuler::DragMargin1()
    1557                 :            : 
    1558                 :            : /* [Description]
    1559                 :            : 
    1560                 :            :    Dragging the left edge of frame
    1561                 :            : */
    1562                 :            : {
    1563 [ #  # ][ #  # ]:          0 :     const long lDragPos = GetCorrectedDragPos( !TAB_FLAG || !NEG_FLAG, sal_True );
                 [ #  # ]
    1564 [ #  # ][ #  # ]:          0 :     DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 3 : 7, bHorz);
                 [ #  # ]
    1565 [ #  # ][ #  # ]:          0 :     if(pColumnItem&&
    1566                 :            :        (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL))
    1567                 :          0 :         DragBorders();
    1568                 :          0 :     AdjustMargin1(lDragPos);
    1569                 :          0 : }
    1570                 :          0 : void SvxRuler::AdjustMargin1(long lDiff)
    1571                 :            : {
    1572         [ #  # ]:          0 :     const long nOld = bAppSetNullOffset? GetMargin1(): GetNullOffset();
    1573                 :          0 :     const long lDragPos = lDiff;
    1574                 :            :     sal_Bool bProtectColumns =
    1575                 :          0 :         pRuler_Imp->aProtectItem.IsSizeProtected() ||
    1576 [ #  # ][ #  # ]:          0 :         pRuler_Imp->aProtectItem.IsPosProtected();
    1577                 :            : 
    1578                 :            :     const sal_uInt16 nMarginStyle =
    1579                 :          0 :         bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE;
    1580                 :            : 
    1581         [ #  # ]:          0 :     if(!bAppSetNullOffset)
    1582                 :            :     {
    1583                 :          0 :         long _lDiff = lDragPos;
    1584                 :          0 :         SetNullOffset(nOld + _lDiff);
    1585 [ #  # ][ #  # ]:          0 :         if(!pColumnItem||!(nDragType & DRAG_OBJECT_SIZE_LINEAR))
    1586                 :            :         {
    1587                 :          0 :             SetMargin2( GetMargin2() - _lDiff, nMarginStyle );
    1588                 :            : 
    1589 [ #  # ][ #  # ]:          0 :             if(!pColumnItem && !pObjectItem && pParaItem)
                 [ #  # ]
    1590                 :            :             {
    1591                 :            :                 // Right indent of the old position
    1592                 :          0 :                 pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
    1593                 :          0 :                 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    1594                 :            :             }
    1595         [ #  # ]:          0 :             if(pObjectItem)
    1596                 :            :             {
    1597                 :          0 :                 pObjectBorders[GetObjectBordersOff(0)].nPos -= _lDiff;
    1598                 :          0 :                 pObjectBorders[GetObjectBordersOff(1)].nPos -= _lDiff;
    1599                 :          0 :                 SetBorders(2, pObjectBorders + GetObjectBordersOff(0));
    1600                 :            :             }
    1601         [ #  # ]:          0 :             if(pColumnItem)
    1602                 :            :             {
    1603         [ #  # ]:          0 :                 for(sal_uInt16 i = 0; i < pColumnItem->Count()-1; ++i)
    1604                 :          0 :                     pBorders[i].nPos -= _lDiff;
    1605                 :          0 :                 SetBorders(pColumnItem->Count()-1, pBorders);
    1606         [ #  # ]:          0 :                 if(pColumnItem->IsFirstAct())
    1607                 :            :                 {
    1608                 :            :                     // Right indent of the old position
    1609         [ #  # ]:          0 :                     if(pParaItem)
    1610                 :            :                     {
    1611                 :          0 :                         pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
    1612                 :          0 :                         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    1613                 :            :                     }
    1614                 :            :                 }
    1615                 :            :                 else
    1616                 :            :                 {
    1617         [ #  # ]:          0 :                     if(pParaItem)
    1618                 :            :                     {
    1619                 :          0 :                         pIndents[INDENT_FIRST_LINE].nPos -= _lDiff;
    1620                 :          0 :                         pIndents[INDENT_LEFT_MARGIN].nPos -= _lDiff;
    1621                 :          0 :                         pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
    1622                 :          0 :                         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    1623                 :            :                     }
    1624                 :            :                 }
    1625         [ #  # ]:          0 :                 if(pTabStopItem&& (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
           [ #  #  #  # ]
                 [ #  # ]
    1626                 :          0 :                    &&!IsActFirstColumn())
    1627                 :            :                 {
    1628                 :          0 :                     ModifyTabs_Impl(nTabCount+TAB_GAP, pTabs, -_lDiff);
    1629                 :          0 :                     SetTabs(nTabCount, pTabs+TAB_GAP);
    1630                 :            :                 }
    1631                 :            :             }
    1632                 :            :         }
    1633                 :            :     }
    1634                 :            :     else
    1635                 :            :     {
    1636                 :          0 :         long _lDiff = lDragPos - nOld;
    1637                 :          0 :         SetMargin1(nOld + _lDiff, nMarginStyle );
    1638                 :            : 
    1639 [ #  # ][ #  # ]:          0 :         if(!pColumnItem||!(nDragType & (DRAG_OBJECT_SIZE_LINEAR |
    1640                 :          0 :                                         DRAG_OBJECT_SIZE_PROPORTIONAL)))
    1641                 :            :         {
    1642 [ #  # ][ #  # ]:          0 :             if(!pColumnItem && !pObjectItem && pParaItem)
                 [ #  # ]
    1643                 :            :             {
    1644                 :            :                 // Left indent of the old position
    1645                 :          0 :                 pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
    1646                 :          0 :                 pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
    1647                 :          0 :                 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    1648                 :            :             }
    1649                 :            : 
    1650         [ #  # ]:          0 :             if(pColumnItem)
    1651                 :            :             {
    1652         [ #  # ]:          0 :                 for(sal_uInt16 i = 0; i < pColumnItem->Count()-1; ++i)
    1653                 :          0 :                     pBorders[i].nPos += _lDiff;
    1654                 :          0 :                 SetBorders(pColumnItem->Count()-1, pBorders);
    1655         [ #  # ]:          0 :                 if(pColumnItem->IsFirstAct())
    1656                 :            :                 {
    1657                 :            :                     // Left indent of the old position
    1658         [ #  # ]:          0 :                     if(pParaItem)
    1659                 :            :                     {
    1660                 :          0 :                         pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
    1661                 :          0 :                         pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
    1662                 :          0 :                         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    1663                 :            :                     }
    1664                 :            :                 }
    1665                 :            :                 else
    1666                 :            :                 {
    1667         [ #  # ]:          0 :                     if(pParaItem)
    1668                 :            :                     {
    1669                 :          0 :                         pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
    1670                 :          0 :                         pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
    1671                 :          0 :                         pIndents[INDENT_RIGHT_MARGIN].nPos += _lDiff;
    1672                 :          0 :                         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    1673                 :            :                     }
    1674                 :            :                 }
    1675                 :            :             }
    1676         [ #  # ]:          0 :             if(pTabStopItem)
    1677                 :            :             {
    1678                 :          0 :                 ModifyTabs_Impl(nTabCount+TAB_GAP, pTabs, _lDiff);
    1679                 :          0 :                 SetTabs(nTabCount, pTabs+TAB_GAP);
    1680                 :            :             }
    1681                 :            :         }
    1682                 :            :     }
    1683                 :          0 : }
    1684                 :            : 
    1685                 :            : 
    1686                 :          0 : void SvxRuler::DragMargin2()
    1687                 :            : 
    1688                 :            : /* [Description]
    1689                 :            : 
    1690                 :            :    Dragging the right edge of frame
    1691                 :            : */
    1692                 :            : {
    1693 [ #  # ][ #  # ]:          0 :     const long lDragPos = GetCorrectedDragPos( sal_True, !TAB_FLAG || !NEG_FLAG);
                 [ #  # ]
    1694 [ #  # ][ #  # ]:          0 :     DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 5 : 7, bHorz);
                 [ #  # ]
    1695                 :          0 :     long lDiff = lDragPos - GetMargin2();
    1696                 :            : 
    1697 [ #  # ][ #  # ]:          0 :     if(pRuler_Imp->bIsTableRows && !bHorz && pColumnItem&&
         [ #  # ][ #  # ]
    1698                 :            :        (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL))
    1699                 :          0 :         DragBorders();
    1700                 :            : 
    1701                 :            :     sal_Bool bProtectColumns =
    1702                 :          0 :         pRuler_Imp->aProtectItem.IsSizeProtected() ||
    1703 [ #  # ][ #  # ]:          0 :         pRuler_Imp->aProtectItem.IsPosProtected();
    1704                 :            :     const sal_uInt16 nMarginStyle =
    1705                 :          0 :         bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE;
    1706                 :          0 :     SetMargin2( lDragPos, nMarginStyle );
    1707                 :            : 
    1708                 :            :     // Right indent of the old position
    1709 [ #  # ][ #  # ]:          0 :     if((!pColumnItem || IsActLastColumn()) && pParaItem)
         [ #  # ][ #  # ]
    1710                 :            :     {
    1711                 :          0 :         pIndents[INDENT_FIRST_LINE].nPos += lDiff;
    1712                 :          0 :         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    1713                 :            :     }
    1714                 :          0 : }
    1715                 :            : 
    1716                 :            : 
    1717                 :          0 : void SvxRuler::DragIndents()
    1718                 :            : 
    1719                 :            : /* [Description]
    1720                 :            : 
    1721                 :            :    Dragging the paragraph indents
    1722                 :            : */
    1723                 :            : {
    1724         [ #  # ]:          0 :     const long lDragPos = NEG_FLAG ? GetDragPos() : GetCorrectedDragPos();
    1725                 :          0 :     const sal_uInt16 nIdx = GetDragAryPos()+INDENT_GAP;
    1726                 :          0 :     const long lDiff = pIndents[nIdx].nPos - lDragPos;
    1727                 :            : 
    1728 [ #  # ][ #  # ]:          0 :     if((nIdx == INDENT_FIRST_LINE ||
                 [ #  # ]
    1729                 :            :             nIdx == INDENT_LEFT_MARGIN )  &&
    1730                 :            :         (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
    1731                 :            :         DRAG_OBJECT_LEFT_INDENT_ONLY)
    1732                 :          0 :         pIndents[INDENT_FIRST_LINE].nPos -= lDiff;
    1733                 :            : 
    1734                 :          0 :     pIndents[nIdx].nPos = lDragPos;
    1735                 :            : 
    1736                 :          0 :     SetIndents(INDENT_COUNT, pIndents + INDENT_GAP);
    1737                 :          0 :     DrawLine_Impl(lTabPos, 1, bHorz);
    1738                 :          0 : }
    1739                 :            : 
    1740                 :            : 
    1741                 :          0 : void SvxRuler::DrawLine_Impl(long &_lTabPos, int nNew, sal_Bool Hori)
    1742                 :            : 
    1743                 :            : /* [Description]
    1744                 :            : 
    1745                 :            :    Output routine for the ledger line when moving tabs, tables and other
    1746                 :            :    columns
    1747                 :            : */
    1748                 :            : {
    1749         [ #  # ]:          0 :     if(Hori)
    1750                 :            :     {
    1751         [ #  # ]:          0 :         const long nHeight = pEditWin->GetOutputSize().Height();
    1752                 :          0 :         Point aZero=pEditWin->GetMapMode().GetOrigin();
    1753         [ #  # ]:          0 :         if(_lTabPos!=-1)
    1754                 :            :             pEditWin->InvertTracking(
    1755                 :          0 :                 Rectangle( Point(_lTabPos, -aZero.Y()),
    1756                 :          0 :                            Point(_lTabPos, -aZero.Y()+nHeight)),
    1757 [ #  # ][ #  # ]:          0 :                 SHOWTRACK_SPLIT | SHOWTRACK_CLIP );
    1758         [ #  # ]:          0 :         if( nNew & 1 )
    1759                 :            :         {
    1760                 :            : 
    1761                 :            :             _lTabPos = ConvertHSizeLogic(
    1762         [ #  # ]:          0 :                 GetCorrectedDragPos( ( nNew&4 ) != 0, ( nNew&2 ) != 0 ) +
    1763 [ #  # ][ #  # ]:          0 :                 GetNullOffset() );
    1764         [ #  # ]:          0 :             if(pPagePosItem)
    1765                 :          0 :                 _lTabPos += pPagePosItem->GetPos().X();
    1766                 :            :             pEditWin->InvertTracking(
    1767                 :          0 :                 Rectangle(Point(_lTabPos, -aZero.Y()),
    1768                 :          0 :                           Point(_lTabPos, -aZero.Y()+nHeight)),
    1769 [ #  # ][ #  # ]:          0 :                 SHOWTRACK_CLIP | SHOWTRACK_SPLIT );
    1770                 :            :         }
    1771                 :            :     }
    1772                 :            :     else
    1773                 :            :     {
    1774         [ #  # ]:          0 :         const long nWidth = pEditWin->GetOutputSize().Width();
    1775                 :          0 :         Point aZero=pEditWin->GetMapMode().GetOrigin();
    1776         [ #  # ]:          0 :         if(_lTabPos != -1)
    1777                 :            :         {
    1778                 :            :             pEditWin->InvertTracking(
    1779                 :          0 :                 Rectangle( Point(-aZero.X(), _lTabPos),
    1780                 :          0 :                            Point(-aZero.X()+nWidth, _lTabPos)),
    1781 [ #  # ][ #  # ]:          0 :                 SHOWTRACK_SPLIT | SHOWTRACK_CLIP );
    1782                 :            :         }
    1783                 :            : 
    1784         [ #  # ]:          0 :         if(nNew & 1)
    1785                 :            :         {
    1786 [ #  # ][ #  # ]:          0 :             _lTabPos = ConvertVSizeLogic(GetCorrectedDragPos()+GetNullOffset());
                 [ #  # ]
    1787         [ #  # ]:          0 :             if(pPagePosItem)
    1788                 :          0 :                 _lTabPos += pPagePosItem->GetPos().Y();
    1789                 :            :             pEditWin->InvertTracking(
    1790                 :          0 :                 Rectangle( Point(-aZero.X(), _lTabPos),
    1791                 :          0 :                            Point(-aZero.X()+nWidth, _lTabPos)),
    1792 [ #  # ][ #  # ]:          0 :                 SHOWTRACK_CLIP | SHOWTRACK_SPLIT );
    1793                 :            :         }
    1794                 :            :     }
    1795                 :          0 : }
    1796                 :            : 
    1797                 :            : 
    1798                 :            : 
    1799                 :            : 
    1800                 :          0 : void SvxRuler::DragTabs()
    1801                 :            : 
    1802                 :            : /* [Description]
    1803                 :            : 
    1804                 :            :    Dragging of Tabs
    1805                 :            : */
    1806                 :            : {
    1807                 :            : 
    1808                 :          0 :     long lDragPos = GetCorrectedDragPos(sal_True, sal_False);
    1809                 :            : 
    1810                 :          0 :     sal_uInt16 nIdx = GetDragAryPos()+TAB_GAP;
    1811                 :          0 :     DrawLine_Impl(lTabPos, 7, bHorz);
    1812                 :            : 
    1813                 :          0 :     long nDiff = lDragPos - pTabs[nIdx].nPos;
    1814                 :            : 
    1815         [ #  # ]:          0 :     if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
    1816                 :            :     {
    1817                 :            : 
    1818         [ #  # ]:          0 :         for(sal_uInt16 i = nIdx; i < nTabCount; ++i)
    1819                 :            :         {
    1820                 :          0 :             pTabs[i].nPos += nDiff;
    1821                 :            :             // limit on maximum
    1822         [ #  # ]:          0 :             if(pTabs[i].nPos > GetMargin2())
    1823                 :          0 :                 pTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
    1824                 :            :             else
    1825                 :          0 :                 pTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
    1826                 :            :         }
    1827                 :            :     }
    1828         [ #  # ]:          0 :     else if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
    1829                 :            :     {
    1830                 :          0 :         pRuler_Imp->nTotalDist -= nDiff;
    1831                 :          0 :         pTabs[nIdx].nPos = lDragPos;
    1832         [ #  # ]:          0 :         for(sal_uInt16 i = nIdx+1; i < nTabCount; ++i)
    1833                 :            :         {
    1834         [ #  # ]:          0 :             if(pTabs[i].nStyle & RULER_TAB_DEFAULT)
    1835                 :            :                 // can be canceled at the DefaultTabs
    1836                 :          0 :                 break;
    1837                 :          0 :             long nDelta = pRuler_Imp->nTotalDist * pRuler_Imp->pPercBuf[i];
    1838                 :          0 :             nDelta /= 1000;
    1839                 :          0 :             pTabs[i].nPos = pTabs[nIdx].nPos + nDelta;
    1840         [ #  # ]:          0 :             if(pTabs[i].nPos+GetNullOffset() > nMaxRight)
    1841                 :          0 :                 pTabs[i].nStyle |= RULER_STYLE_INVISIBLE;
    1842                 :            :             else
    1843                 :          0 :                 pTabs[i].nStyle &= ~RULER_STYLE_INVISIBLE;
    1844                 :            :         }
    1845                 :            :     }
    1846                 :            :     else
    1847                 :          0 :         pTabs[nIdx].nPos = lDragPos;
    1848                 :            : 
    1849         [ #  # ]:          0 :     if(IsDragDelete())
    1850                 :          0 :         pTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
    1851                 :            :     else
    1852                 :          0 :         pTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
    1853                 :          0 :     SetTabs(nTabCount, pTabs+TAB_GAP);
    1854                 :          0 : }
    1855                 :            : 
    1856                 :            : 
    1857                 :            : 
    1858                 :      12350 : void SvxRuler::SetActive(sal_Bool bOn)
    1859                 :            : {
    1860         [ +  + ]:      12350 :     if(bOn)
    1861                 :            :     {
    1862                 :       6078 :         Activate();
    1863                 :            :     }
    1864                 :            :     else
    1865                 :       6272 :         Deactivate();
    1866         [ +  + ]:      12350 :     if(bActive!=bOn)
    1867                 :            :     {
    1868                 :       8452 :         pBindings->EnterRegistrations();
    1869         [ +  + ]:       8452 :         if(bOn)
    1870         [ +  + ]:      30428 :             for(sal_uInt16 i=0;i<pRuler_Imp->nControlerItems;i++)
    1871                 :      27624 :                 pCtrlItem[i]->ReBind();
    1872                 :            :         else
    1873         [ +  + ]:      61296 :             for(sal_uInt16 j=0;j<pRuler_Imp->nControlerItems;j++)
    1874                 :      55648 :                 pCtrlItem[j]->UnBind();
    1875                 :       8452 :         pBindings->LeaveRegistrations();
    1876                 :            :     }
    1877                 :      12350 :     bActive = bOn;
    1878                 :      12350 : }
    1879                 :            : 
    1880                 :            : 
    1881                 :            : 
    1882                 :            : 
    1883                 :          0 : void SvxRuler::UpdateParaContents_Impl
    1884                 :            : (
    1885                 :            :  long l,           // Difference
    1886                 :            :  UpdateType eType  // Art (all, left or right)
    1887                 :            : )
    1888                 :            : 
    1889                 :            : /* [Description]
    1890                 :            : 
    1891                 :            :    Helper function; carry Tabs and Paragraph Margins
    1892                 :            : */
    1893                 :            : {
    1894   [ #  #  #  # ]:          0 :     switch(eType) {
    1895                 :            :     case MOVE_RIGHT:
    1896                 :          0 :         pIndents[INDENT_RIGHT_MARGIN].nPos += l;
    1897                 :          0 :         break;
    1898                 :            :     case MOVE_ALL:
    1899                 :          0 :         pIndents[INDENT_RIGHT_MARGIN].nPos += l;
    1900                 :            :         // no break
    1901                 :            :     case MOVE_LEFT:
    1902                 :            :         {
    1903                 :          0 :             pIndents[INDENT_FIRST_LINE].nPos += l;
    1904                 :          0 :             pIndents[INDENT_LEFT_MARGIN].nPos += l;
    1905         [ #  # ]:          0 :             if ( pTabs )
    1906                 :            :             {
    1907         [ #  # ]:          0 :                 for(sal_uInt16 i = 0; i < nTabCount+TAB_GAP;++i)
    1908                 :          0 :                     pTabs[i].nPos += l;
    1909                 :          0 :                 SetTabs(nTabCount, pTabs+TAB_GAP);
    1910                 :            :             }
    1911                 :          0 :             break;
    1912                 :            :         }
    1913                 :            :     }
    1914                 :          0 :     SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    1915                 :          0 : }
    1916                 :            : 
    1917                 :            : 
    1918                 :          0 : void SvxRuler::DragBorders()
    1919                 :            : 
    1920                 :            : /* [Description]
    1921                 :            : 
    1922                 :            :    Dragging of Borders (Tables and other columns)
    1923                 :            : */
    1924                 :            : {
    1925                 :          0 :     sal_Bool bLeftIndentsCorrected = sal_False, bRightIndentsCorrected = sal_False;
    1926                 :            :     int nIdx;
    1927                 :            : 
    1928         [ #  # ]:          0 :     if(GetDragType()==RULER_TYPE_BORDER)
    1929                 :            :     {
    1930                 :          0 :         DrawLine_Impl(lTabPos, 7, bHorz);
    1931                 :          0 :         nIdx = GetDragAryPos();
    1932                 :            :     }
    1933                 :            :     else
    1934                 :          0 :         nIdx=0;
    1935                 :            : 
    1936                 :          0 :     sal_uInt16 nDragSize = GetDragSize();
    1937                 :          0 :     long lDiff = 0;
    1938                 :            : 
    1939                 :            :     // the drag position has to be corrected to be able to prevent borders from passing each other
    1940                 :          0 :     long lPos = GetCorrectedDragPos();
    1941                 :            : 
    1942                 :            : 
    1943   [ #  #  #  # ]:          0 :     switch(nDragSize)
    1944                 :            :     {
    1945                 :            :       case RULER_DRAGSIZE_MOVE:
    1946                 :            :         {
    1947                 :            : ADD_DEBUG_TEXT("lLastLMargin: ", String::CreateFromInt32(pRuler_Imp->lLastLMargin))
    1948                 :          0 :             lDiff = GetDragType()==RULER_TYPE_BORDER ?
    1949                 :          0 :                 lPos-nDragOffset - pBorders[nIdx].nPos
    1950 [ #  # ][ #  # ]:          0 :                 : GetDragType() == RULER_TYPE_MARGIN1 ? lPos - pRuler_Imp->lLastLMargin : lPos - pRuler_Imp->lLastRMargin;
    1951                 :            : 
    1952         [ #  # ]:          0 :             if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
    1953                 :            :             {
    1954                 :          0 :                 long nRight = GetMargin2()-lMinFrame; // Right limiters
    1955         [ #  # ]:          0 :                 for(int i = nBorderCount-2; i >= nIdx; --i)
    1956                 :            :                 {
    1957                 :          0 :                     long l = pBorders[i].nPos;
    1958                 :          0 :                     pBorders[i].nPos += lDiff;
    1959                 :          0 :                     pBorders[i].nPos = Min(pBorders[i].nPos, nRight - pBorders[i].nWidth);
    1960                 :          0 :                     nRight = pBorders[i].nPos - lMinFrame;
    1961                 :            :                     // RR update the column
    1962         [ #  # ]:          0 :                     if(i == GetActRightColumn())
    1963                 :            :                     {
    1964                 :          0 :                         UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_RIGHT);
    1965                 :          0 :                         bRightIndentsCorrected = sal_True;
    1966                 :            :                     }
    1967                 :            :                     // LAR, EZE update the column
    1968         [ #  # ]:          0 :                     else if(i == GetActLeftColumn())
    1969                 :            :                     {
    1970                 :          0 :                         UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_LEFT);
    1971                 :          0 :                         bLeftIndentsCorrected = sal_True;
    1972                 :            :                     }
    1973                 :            :                 }
    1974                 :            :             }
    1975         [ #  # ]:          0 :             else if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
    1976                 :            :             {
    1977                 :            :                 int nLimit;
    1978                 :            :                 long lLeft;
    1979                 :          0 :                 int nStartLimit = nBorderCount-2;
    1980      [ #  #  # ]:          0 :                 switch(GetDragType())
    1981                 :            :                 {
    1982                 :            :                 default: ;//prevent warning
    1983                 :            :                     OSL_FAIL("svx::SvxRuler::DragBorders(), unknown drag type!" );
    1984                 :            :                 case RULER_TYPE_BORDER:
    1985         [ #  # ]:          0 :                     if(pRuler_Imp->bIsTableRows)
    1986                 :            :                     {
    1987                 :          0 :                         pBorders[nIdx].nPos += lDiff;
    1988         [ #  # ]:          0 :                         if(bHorz)
    1989                 :            :                         {
    1990                 :          0 :                             lLeft = pBorders[nIdx].nPos;
    1991                 :          0 :                             pRuler_Imp->nTotalDist -= lDiff;
    1992                 :          0 :                             nLimit=nIdx+1;
    1993                 :            :                         }
    1994                 :            :                         else
    1995                 :            :                         {
    1996                 :          0 :                             lLeft = 0;
    1997                 :          0 :                             nStartLimit = nIdx - 1;
    1998                 :          0 :                             pRuler_Imp->nTotalDist += lDiff;
    1999                 :          0 :                             nLimit = 0;
    2000                 :            :                         }
    2001                 :            :                     }
    2002                 :            :                     else
    2003                 :            :                     {
    2004                 :          0 :                         nLimit=nIdx+1;
    2005                 :          0 :                         pBorders[nIdx].nPos += lDiff;
    2006                 :          0 :                         lLeft = pBorders[nIdx].nPos;
    2007                 :          0 :                         pRuler_Imp->nTotalDist-=lDiff;
    2008                 :            :                     }
    2009                 :          0 :                 break;
    2010                 :            :                 case RULER_TYPE_MARGIN1:
    2011                 :          0 :                     nLimit=0;
    2012                 :          0 :                     lLeft=pRuler_Imp->lLastLMargin+lDiff;
    2013                 :          0 :                     pRuler_Imp->nTotalDist-=lDiff;
    2014                 :          0 :                 break;
    2015                 :            :                 case RULER_TYPE_MARGIN2:
    2016                 :          0 :                     nLimit = 0;
    2017                 :          0 :                     lLeft= 0;
    2018                 :          0 :                     nStartLimit = nBorderCount - 2;
    2019                 :          0 :                     pRuler_Imp->nTotalDist += lDiff;
    2020                 :          0 :                 break;
    2021                 :            :                 }
    2022                 :            : 
    2023         [ #  # ]:          0 :                 for(int i  = nStartLimit; i >= nLimit; --i)
    2024                 :            :                 {
    2025                 :            : 
    2026                 :          0 :                     long l = pBorders[i].nPos;
    2027                 :          0 :                     pBorders[i].nPos=lLeft+
    2028                 :          0 :                         (pRuler_Imp->nTotalDist*pRuler_Imp->pPercBuf[i])/1000+
    2029                 :          0 :                             pRuler_Imp->pBlockBuf[i];
    2030                 :            : 
    2031                 :            :                     // RR update the column
    2032         [ #  # ]:          0 :                     if(!pRuler_Imp->bIsTableRows)
    2033                 :            :                     {
    2034         [ #  # ]:          0 :                         if(i == GetActRightColumn())
    2035                 :            :                         {
    2036                 :          0 :                             UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_RIGHT);
    2037                 :          0 :                             bRightIndentsCorrected = sal_True;
    2038                 :            :                         }
    2039                 :            :                         // LAR, EZE update the column
    2040         [ #  # ]:          0 :                         else if(i == GetActLeftColumn())
    2041                 :            :                         {
    2042                 :          0 :                             UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_LEFT);
    2043                 :          0 :                             bLeftIndentsCorrected = sal_True;
    2044                 :            :                         }
    2045                 :            :                     }
    2046                 :            :                 }
    2047         [ #  # ]:          0 :                 if(pRuler_Imp->bIsTableRows)
    2048                 :            :                 {
    2049                 :            :                     //in vertical tables the left borders have to be moved
    2050         [ #  # ]:          0 :                     if(bHorz)
    2051                 :            :                     {
    2052         [ #  # ]:          0 :                         for(int i  = 0; i < nIdx; ++i)
    2053                 :          0 :                             pBorders[i].nPos += lDiff;
    2054                 :          0 :                         AdjustMargin1(lDiff);
    2055                 :            :                     }
    2056                 :            :                     else
    2057                 :            :                     {
    2058                 :            :                         //otherwise the right borders are moved
    2059         [ #  # ]:          0 :                         for(int i  = pColumnItem->Count() - 1; i > nIdx; --i)
    2060                 :          0 :                             pBorders[i].nPos += lDiff;
    2061                 :          0 :                         SetMargin2( GetMargin2() + lDiff, 0 );
    2062                 :            :                     }
    2063                 :            :                 }
    2064                 :            :             }
    2065         [ #  # ]:          0 :             else if(pRuler_Imp->bIsTableRows)
    2066                 :            :             {
    2067                 :            :                 //moving rows: if a row is resized all following rows
    2068                 :            :                 //have to be moved by the same amount.
    2069                 :            :                 //This includes the left border when the table is not limited
    2070                 :            :                 //to a lower frame border.
    2071                 :            :                 int nLimit;
    2072         [ #  # ]:          0 :                 if(GetDragType()==RULER_TYPE_BORDER)
    2073                 :            :                 {
    2074                 :          0 :                     nLimit=nIdx+1;
    2075                 :          0 :                     pBorders[nIdx].nPos+=lDiff;
    2076                 :            :                 }
    2077                 :            :                 else
    2078                 :            :                 {
    2079                 :          0 :                     nLimit=0;
    2080                 :            :                 }
    2081                 :            :                 //in vertical tables the left borders have to be moved
    2082         [ #  # ]:          0 :                 if(bHorz)
    2083                 :            :                 {
    2084         [ #  # ]:          0 :                     for(int i  = 0; i < nIdx; ++i)
    2085                 :            :                     {
    2086                 :          0 :                         pBorders[i].nPos += lDiff;
    2087                 :            :                     }
    2088                 :          0 :                     AdjustMargin1(lDiff);
    2089                 :            :                 }
    2090                 :            :                 else
    2091                 :            :                 {
    2092                 :            :                     //otherwise the right borders are moved
    2093         [ #  # ]:          0 :                     for(int i  = nBorderCount-2; i >= nLimit; --i)
    2094                 :            :                     {
    2095                 :          0 :                         pBorders[i].nPos += lDiff;
    2096                 :            :                     }
    2097                 :          0 :                     SetMargin2( GetMargin2() + lDiff, 0 );
    2098                 :            :                 }
    2099                 :            :             }
    2100                 :            :             else
    2101                 :          0 :                 pBorders[nIdx].nPos+=lDiff;
    2102                 :          0 :             break;
    2103                 :            :         }
    2104                 :            :       case RULER_DRAGSIZE_1:
    2105                 :            :         {
    2106                 :          0 :             lDiff = lPos - pBorders[nIdx].nPos;
    2107                 :          0 :             pBorders[nIdx].nWidth += pBorders[nIdx].nPos - lPos;
    2108                 :          0 :             pBorders[nIdx].nPos = lPos;
    2109                 :          0 :             break;
    2110                 :            :         }
    2111                 :            :       case RULER_DRAGSIZE_2:
    2112                 :            :         {
    2113                 :          0 :             const long nOld = pBorders[nIdx].nWidth;
    2114                 :          0 :             pBorders[nIdx].nWidth = lPos - pBorders[nIdx].nPos;
    2115                 :          0 :             lDiff = pBorders[nIdx].nWidth - nOld;
    2116                 :          0 :             break;
    2117                 :            :         }
    2118                 :            :     }
    2119   [ #  #  #  # ]:          0 :     if(!bRightIndentsCorrected &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2120                 :          0 :        GetActRightColumn() == nIdx &&
    2121                 :            :        nDragSize != RULER_DRAGSIZE_2 && pIndents &&
    2122                 :          0 :        !pRuler_Imp->bIsTableRows)
    2123                 :            :     {
    2124                 :          0 :         UpdateParaContents_Impl(lDiff, MOVE_RIGHT);
    2125                 :            :     }
    2126   [ #  #  #  # ]:          0 :     else if(!bLeftIndentsCorrected &&
         [ #  # ][ #  # ]
                 [ #  # ]
    2127                 :          0 :             GetActLeftColumn()==nIdx &&
    2128                 :            :             nDragSize != RULER_DRAGSIZE_1 && pIndents)
    2129                 :            :     {
    2130                 :          0 :         UpdateParaContents_Impl(lDiff, MOVE_LEFT);
    2131                 :            :     }
    2132                 :          0 :     SetBorders(pColumnItem->Count()-1, pBorders);
    2133                 :          0 : }
    2134                 :            : 
    2135                 :            : 
    2136                 :          0 : void SvxRuler::DragObjectBorder()
    2137                 :            : 
    2138                 :            : /* [Description]
    2139                 :            : 
    2140                 :            :    Dragging of object edges
    2141                 :            : */
    2142                 :            : {
    2143         [ #  # ]:          0 :     if(RULER_DRAGSIZE_MOVE == GetDragSize())
    2144                 :            :     {
    2145                 :          0 :         const long lPos = GetCorrectedDragPos();
    2146                 :          0 :         const sal_uInt16 nIdx = GetDragAryPos();
    2147                 :          0 :         pObjectBorders[GetObjectBordersOff(nIdx)].nPos = lPos;
    2148                 :          0 :         SetBorders(2, pObjectBorders + GetObjectBordersOff(0));
    2149                 :          0 :         DrawLine_Impl(lTabPos, 7, bHorz);
    2150                 :            : 
    2151                 :            :     }
    2152                 :          0 : }
    2153                 :            : 
    2154                 :            : 
    2155                 :          0 : void SvxRuler::ApplyMargins()
    2156                 :            : 
    2157                 :            : /* [Description]
    2158                 :            : 
    2159                 :            :    Applying margins; changed by dragging.
    2160                 :            : */
    2161                 :            : {
    2162                 :          0 :     const SfxPoolItem *pItem = 0;
    2163                 :          0 :     sal_uInt16 nId = SID_ATTR_LONG_LRSPACE;
    2164         [ #  # ]:          0 :     if(bHorz)
    2165                 :            :     {
    2166                 :          0 :         const long lOldNull = lLogicNullOffset;
    2167 [ #  # ][ #  # ]:          0 :         if(pRuler_Imp->lMaxLeftLogic!=-1&&nMaxLeft==GetMargin1()+Ruler::GetNullOffset())
                 [ #  # ]
    2168                 :          0 :             pLRSpaceItem->SetLeft(lLogicNullOffset=pRuler_Imp->lMaxLeftLogic);
    2169                 :            :         else
    2170                 :            :             pLRSpaceItem->SetLeft(PixelHAdjust(
    2171                 :          0 :                 lLogicNullOffset =  ConvertHPosLogic(GetFrameLeft()) -
    2172                 :          0 :                 lAppNullOffset, pLRSpaceItem->GetLeft()));
    2173                 :            : 
    2174         [ #  # ]:          0 :         if(bAppSetNullOffset)
    2175                 :          0 :             lAppNullOffset += lLogicNullOffset - lOldNull;
    2176                 :            : 
    2177   [ #  #  #  # ]:          0 :         if(pRuler_Imp->lMaxRightLogic!=-1
                 [ #  # ]
    2178                 :          0 :            &&nMaxRight==GetMargin2()+Ruler::GetNullOffset())
    2179                 :          0 :             pLRSpaceItem->SetRight(GetPageWidth()-pRuler_Imp->lMaxRightLogic);
    2180                 :            :         else
    2181                 :            :             pLRSpaceItem->SetRight(
    2182                 :            :                 PixelHAdjust(
    2183                 :          0 :                     Max((long)0,pPagePosItem->GetWidth() -
    2184                 :          0 :                         pLRSpaceItem->GetLeft() -
    2185                 :          0 :                         (ConvertHPosLogic(GetMargin2()) -
    2186                 :          0 :                          lAppNullOffset)),pLRSpaceItem->GetRight()));
    2187                 :          0 :         pItem = pLRSpaceItem;
    2188                 :            : #ifdef DEBUGLIN
    2189                 :            :         Debug_Impl(pEditWin,*pLRSpaceItem);
    2190                 :            : #endif // DEBUGLIN
    2191                 :            :     }
    2192                 :            :     else {
    2193                 :          0 :         const long lOldNull = lLogicNullOffset;
    2194                 :            :         pULSpaceItem->SetUpper(
    2195                 :            :             PixelVAdjust(
    2196                 :            :                 lLogicNullOffset =
    2197                 :          0 :                 ConvertVPosLogic(GetFrameLeft()) -
    2198                 :          0 :                 lAppNullOffset,pULSpaceItem->GetUpper()));
    2199         [ #  # ]:          0 :         if(bAppSetNullOffset)
    2200                 :          0 :             lAppNullOffset += lLogicNullOffset - lOldNull;
    2201                 :            :         pULSpaceItem->SetLower(
    2202                 :            :             PixelVAdjust(
    2203                 :          0 :                 Max((long)0, pPagePosItem->GetHeight() -
    2204                 :          0 :                     pULSpaceItem->GetUpper() -
    2205                 :          0 :                     (ConvertVPosLogic(GetMargin2()) -
    2206                 :          0 :                      lAppNullOffset)),pULSpaceItem->GetLower()));
    2207                 :          0 :         pItem = pULSpaceItem;
    2208                 :          0 :         nId = SID_ATTR_LONG_ULSPACE;
    2209                 :            : #ifdef DEBUGLIN
    2210                 :            :         Debug_Impl(pEditWin,*pULSpaceItem);
    2211                 :            : #endif // DEBUGLIN
    2212                 :            :     }
    2213                 :          0 :     pBindings->GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, pItem, 0L );
    2214         [ #  # ]:          0 :     if(pTabStopItem)
    2215                 :          0 :         UpdateTabs();
    2216                 :          0 : }
    2217                 :            : 
    2218                 :            : 
    2219                 :          0 : void SvxRuler::ApplyIndents()
    2220                 :            : 
    2221                 :            : /* [Description]
    2222                 :            : 
    2223                 :            :    Applying paragraph settings; changed by dragging.
    2224                 :            : */
    2225                 :            : {
    2226                 :            :     long nNewTxtLeft;
    2227 [ #  # ][ #  # ]:          0 :     if(pColumnItem&&!IsActFirstColumn( sal_True ))
                 [ #  # ]
    2228                 :            :     {
    2229                 :          0 :         long nLeftCol=GetActLeftColumn( sal_True );
    2230                 :            :         nNewTxtLeft =
    2231                 :            :             PixelHAdjust(
    2232                 :            :                 ConvertHPosLogic(
    2233                 :          0 :                     pIndents[INDENT_LEFT_MARGIN].nPos-
    2234                 :          0 :                     (pBorders[nLeftCol].nPos +
    2235                 :          0 :                      pBorders[nLeftCol].nWidth))-
    2236                 :          0 :                 lAppNullOffset,pParaItem->GetTxtLeft());
    2237                 :            :     }
    2238                 :            :     else
    2239                 :            :         nNewTxtLeft =
    2240                 :            :             PixelHAdjust(
    2241                 :          0 :                 ConvertHPosLogic(pIndents[INDENT_LEFT_MARGIN].nPos),
    2242                 :          0 :                 pParaItem->GetTxtLeft());
    2243                 :            : 
    2244 [ #  # ][ #  # ]:          0 :     sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
    2245                 :            : 
    2246                 :            :     long nNewFirstLineOffset;
    2247         [ #  # ]:          0 :     if(bRTL)
    2248                 :            :     {
    2249                 :          0 :         long nRightFrameMargin = GetRightFrameMargin();
    2250                 :            :         nNewFirstLineOffset =   PixelHAdjust(nRightFrameMargin -
    2251                 :          0 :                 ConvertHPosLogic(pIndents[INDENT_FIRST_LINE].nPos ) -
    2252                 :            :                 lAppNullOffset,
    2253                 :          0 :                 pParaItem->GetTxtFirstLineOfst());
    2254                 :            :     }
    2255                 :            :     else
    2256                 :            :         nNewFirstLineOffset=
    2257                 :            :             PixelHAdjust(
    2258                 :          0 :                 ConvertHPosLogic(pIndents[INDENT_FIRST_LINE].nPos -
    2259                 :          0 :                              pIndents[INDENT_LEFT_MARGIN].nPos) -
    2260                 :            :                 lAppNullOffset,
    2261                 :          0 :                 pParaItem->GetTxtFirstLineOfst());
    2262                 :            : 
    2263                 :            :     // If the new TxtLeft is smaller than the old FirstLineIndent, then the
    2264                 :            :     // difference is lost and the paragraph is in total indented too far,
    2265                 :            :     // so first set the FirstLineOffset, then the TxtLeft
    2266                 :            : 
    2267         [ #  # ]:          0 :     if(bRTL)
    2268                 :            :     {
    2269                 :          0 :         long nLeftFrameMargin = GetLeftFrameMargin();
    2270                 :          0 :         long nRightFrameMargin = GetRightFrameMargin();
    2271                 :          0 :         nNewTxtLeft = nRightFrameMargin - nNewTxtLeft - nLeftFrameMargin;
    2272                 :          0 :         nNewFirstLineOffset -= nNewTxtLeft;
    2273         [ #  # ]:          0 :         if(pParaBorderItem)
    2274                 :            :         {
    2275                 :          0 :             nNewTxtLeft += pParaBorderItem->GetLeft() + pParaBorderItem->GetRight();
    2276                 :          0 :             nNewFirstLineOffset -= pParaBorderItem->GetRight();
    2277                 :            :         }
    2278                 :            :     }
    2279                 :            :     pParaItem->SetTxtFirstLineOfst(
    2280                 :          0 :         sal::static_int_cast< short >(nNewFirstLineOffset));
    2281                 :          0 :     pParaItem->SetTxtLeft(nNewTxtLeft);
    2282                 :            : 
    2283 [ #  # ][ #  # ]:          0 :     if(pColumnItem && ((!bRTL && !IsActLastColumn( sal_True ))|| (bRTL && !IsActFirstColumn())))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2284                 :            :     {
    2285         [ #  # ]:          0 :         if(bRTL)
    2286                 :            :         {
    2287                 :          0 :             long nActBorder = pBorders[GetActLeftColumn( sal_True )].nPos;
    2288                 :          0 :             long nRightMargin = pIndents[INDENT_RIGHT_MARGIN].nPos;
    2289                 :          0 :             long nConvert = ConvertHPosLogic( nRightMargin - nActBorder );
    2290                 :          0 :             pParaItem->SetRight( PixelHAdjust( nConvert - lAppNullOffset, pParaItem->GetRight() ) );
    2291                 :            :         }
    2292                 :            :         else
    2293                 :            :         {
    2294                 :            :             pParaItem->SetRight(
    2295                 :            :                 PixelHAdjust(
    2296                 :            :                     ConvertHPosLogic(
    2297                 :          0 :                         pBorders[GetActRightColumn( sal_True )].nPos -
    2298                 :          0 :                         pIndents[INDENT_RIGHT_MARGIN].nPos) -
    2299                 :            :                     lAppNullOffset,
    2300                 :          0 :                     pParaItem->GetRight()));
    2301                 :            :         }
    2302                 :            : 
    2303                 :            :     }
    2304                 :            :     else
    2305                 :            :     {
    2306         [ #  # ]:          0 :         if(bRTL)
    2307                 :            :         {
    2308                 :            :             pParaItem->SetRight( PixelHAdjust(
    2309                 :          0 :                 ConvertHPosLogic(GetMargin1() +
    2310                 :          0 :                              pIndents[INDENT_RIGHT_MARGIN].nPos) - GetLeftFrameMargin() +
    2311                 :          0 :                              (pParaBorderItem ? pParaBorderItem->GetLeft() : 0) -
    2312         [ #  # ]:          0 :                 lAppNullOffset, pParaItem->GetRight()));
    2313                 :            :         }
    2314                 :            :         else
    2315                 :            :         {
    2316                 :            :             pParaItem->SetRight( PixelHAdjust(
    2317                 :          0 :                 ConvertHPosLogic(GetMargin2() -
    2318                 :          0 :                              pIndents[INDENT_RIGHT_MARGIN].nPos) -
    2319                 :          0 :                 lAppNullOffset, pParaItem->GetRight()));
    2320                 :            :         }
    2321                 :            :     }
    2322         [ #  # ]:          0 :     sal_uInt16 nParaId  = bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL;
    2323                 :          0 :     pBindings->GetDispatcher()->Execute( nParaId, SFX_CALLMODE_RECORD, pParaItem, 0L );
    2324                 :          0 :     UpdateTabs();
    2325                 :          0 : }
    2326                 :            : 
    2327                 :            : 
    2328                 :          0 : void SvxRuler::ApplyTabs()
    2329                 :            : 
    2330                 :            : /* [Description]
    2331                 :            : 
    2332                 :            :    Apply tab settings, changed by dragging.
    2333                 :            : */
    2334                 :            : {
    2335 [ #  # ][ #  # ]:          0 :     sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
    2336                 :          0 :     const sal_uInt16 nCoreIdx = GetDragAryPos();
    2337         [ #  # ]:          0 :     if(IsDragDelete())
    2338                 :            :     {
    2339                 :          0 :         pTabStopItem->Remove(nCoreIdx);
    2340                 :            :     }
    2341 [ #  # ][ #  # ]:          0 :     else if(DRAG_OBJECT_SIZE_LINEAR & nDragType ||
    2342                 :            :             DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType)
    2343                 :            :     {
    2344         [ #  # ]:          0 :         SvxTabStopItem *pItem = new SvxTabStopItem(pTabStopItem->Which());
    2345                 :            :         //remove default tab stops
    2346         [ #  # ]:          0 :         for ( sal_uInt16 i = 0; i < pItem->Count(); )
    2347                 :            :         {
    2348         [ #  # ]:          0 :             if ( SVX_TAB_ADJUST_DEFAULT == (*pItem)[i].GetAdjustment() )
    2349                 :            :             {
    2350                 :          0 :                 pItem->Remove(i);
    2351                 :          0 :                 continue;
    2352                 :            :             }
    2353                 :          0 :             ++i;
    2354                 :            :         }
    2355                 :            : 
    2356                 :            :         sal_uInt16 j;
    2357         [ #  # ]:          0 :         for(j = 0; j < nCoreIdx; ++j)
    2358                 :            :         {
    2359                 :          0 :             pItem->Insert((*pTabStopItem)[j]);
    2360                 :            :         }
    2361         [ #  # ]:          0 :         for(; j < pTabStopItem->Count(); ++j)
    2362                 :            :         {
    2363         [ #  # ]:          0 :             SvxTabStop aTabStop = (*pTabStopItem)[j];
    2364                 :          0 :             aTabStop.GetTabPos() = PixelHAdjust(
    2365                 :          0 :                 ConvertHPosLogic(pTabs[j+TAB_GAP].nPos -
    2366 [ #  # ][ #  # ]:          0 :                                  GetLeftIndent()) -
    2367                 :            :                 lAppNullOffset,
    2368         [ #  # ]:          0 :                 aTabStop.GetTabPos());
    2369         [ #  # ]:          0 :             pItem->Insert(aTabStop);
    2370                 :            :         }
    2371         [ #  # ]:          0 :         delete pTabStopItem;
    2372                 :          0 :         pTabStopItem = pItem;
    2373                 :            :     }
    2374         [ #  # ]:          0 :     else if( pTabStopItem->Count() == 0 )
    2375                 :          0 :         return;
    2376                 :            :     else
    2377                 :            :     {
    2378         [ #  # ]:          0 :         SvxTabStop aTabStop = (*pTabStopItem)[nCoreIdx];
    2379 [ #  # ][ #  # ]:          0 :         if(pRuler_Imp->lMaxRightLogic!=-1&&
                 [ #  # ]
    2380         [ #  # ]:          0 :            pTabs[nCoreIdx+TAB_GAP].nPos+Ruler::GetNullOffset()==nMaxRight)
    2381                 :          0 :             aTabStop.GetTabPos() = pRuler_Imp->lMaxRightLogic-lLogicNullOffset;
    2382                 :            :         else
    2383                 :            :         {
    2384         [ #  # ]:          0 :             if(bRTL)
    2385                 :            :             {
    2386                 :            :                 //#i24363# tab stops relative to indent
    2387                 :            :                 const long nTmpLeftIndent = pRuler_Imp->bIsTabsRelativeToIndent ?
    2388                 :            :                                             GetLeftIndent() :
    2389 [ #  # ][ #  # ]:          0 :                                             ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset );
         [ #  # ][ #  # ]
    2390                 :            : 
    2391                 :          0 :                 aTabStop.GetTabPos() = PixelHAdjust(
    2392         [ #  # ]:          0 :                     ConvertHPosLogic( nTmpLeftIndent - pTabs[nCoreIdx+TAB_GAP].nPos) - lAppNullOffset,
    2393         [ #  # ]:          0 :                                                                                         aTabStop.GetTabPos());
    2394                 :            :             }
    2395                 :            :             else
    2396                 :            :             {
    2397                 :            :                 //#i24363# tab stops relative to indent
    2398                 :            :                 const long nTmpLeftIndent = pRuler_Imp->bIsTabsRelativeToIndent ?
    2399                 :            :                                             GetLeftIndent() :
    2400 [ #  # ][ #  # ]:          0 :                                             0;
    2401                 :            : 
    2402                 :          0 :                 aTabStop.GetTabPos() = PixelHAdjust(
    2403         [ #  # ]:          0 :                     ConvertHPosLogic( pTabs[nCoreIdx+TAB_GAP].nPos - nTmpLeftIndent ) - lAppNullOffset,
    2404         [ #  # ]:          0 :                                                                                          aTabStop.GetTabPos() );
    2405                 :            :             }
    2406                 :            :         }
    2407         [ #  # ]:          0 :         pTabStopItem->Remove(nCoreIdx);
    2408         [ #  # ]:          0 :         pTabStopItem->Insert(aTabStop);
    2409                 :            :     }
    2410         [ #  # ]:          0 :     sal_uInt16 nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
    2411                 :          0 :     pBindings->GetDispatcher()->Execute( nTabStopId, SFX_CALLMODE_RECORD, pTabStopItem, 0L );
    2412                 :          0 :     UpdateTabs();
    2413                 :            : }
    2414                 :            : 
    2415                 :            : 
    2416                 :          0 : void SvxRuler::ApplyBorders()
    2417                 :            : 
    2418                 :            : /* [Description]
    2419                 :            : 
    2420                 :            :    Applying (table) column settings; changed by dragging.
    2421                 :            : */
    2422                 :            : {
    2423         [ #  # ]:          0 :     if(pColumnItem->IsTable())
    2424                 :            :     {
    2425         [ #  # ]:          0 :         long l = GetFrameLeft();
    2426         [ #  # ]:          0 :         if(l != pRuler_Imp->nColLeftPix)
    2427                 :            :             pColumnItem->SetLeft( PixelHAdjust(
    2428 [ #  # ][ #  # ]:          0 :                 ConvertHPosLogic(l) - lAppNullOffset, pColumnItem->GetLeft()));
    2429         [ #  # ]:          0 :         l = GetMargin2();
    2430         [ #  # ]:          0 :         if(l != pRuler_Imp->nColRightPix)
    2431                 :            :         {
    2432         [ #  # ]:          0 :             long nWidthOrHeight = bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
    2433                 :            :             pColumnItem->SetRight( PixelHAdjust( nWidthOrHeight -
    2434         [ #  # ]:          0 :                     pColumnItem->GetLeft() - ConvertHPosLogic(l) -
    2435         [ #  # ]:          0 :                     lAppNullOffset, pColumnItem->GetRight() ) );
    2436                 :            :         }
    2437                 :            :     }
    2438         [ #  # ]:          0 :     for(sal_uInt16 i = 0; i < pColumnItem->Count()-1; ++i)
    2439                 :            :     {
    2440         [ #  # ]:          0 :         long& nEnd = (*pColumnItem)[i].nEnd;
    2441 [ #  # ][ #  # ]:          0 :         nEnd = PIXEL_H_ADJUST(
                 [ #  # ]
    2442                 :            :             ConvertPosLogic(pBorders[i].nPos),
    2443                 :          0 :             (*pColumnItem)[i].nEnd);
    2444         [ #  # ]:          0 :         long& nStart = (*pColumnItem)[i+1].nStart;
    2445 [ #  # ][ #  # ]:          0 :         nStart = PIXEL_H_ADJUST(
                 [ #  # ]
    2446                 :            :             ConvertSizeLogic(pBorders[i].nPos +
    2447                 :            :                              pBorders[i].nWidth) -
    2448                 :            :             lAppNullOffset,
    2449                 :          0 :             (*pColumnItem)[i+1].nStart);
    2450                 :            :         // It may be that, due to the PIXEL_H_ADJUST readjustment to old values,
    2451                 :            :         // the width becomes  < 0. This we readjust.
    2452         [ #  # ]:          0 :         if( nEnd > nStart )
    2453                 :          0 :             nStart = nEnd;
    2454                 :            :     }
    2455                 :            : #ifdef DEBUGLIN
    2456                 :            :         Debug_Impl(pEditWin,*pColumnItem);
    2457                 :            : #endif // DEBUGLIN
    2458                 :            :     SfxBoolItem aFlag(SID_RULER_ACT_LINE_ONLY,
    2459 [ #  # ][ #  # ]:          0 :                       nDragType & DRAG_OBJECT_ACTLINE_ONLY? sal_True : sal_False);
    2460                 :            :     sal_uInt16 nColId = pRuler_Imp->bIsTableRows ? (bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL) :
    2461 [ #  # ][ #  # ]:          0 :                             (bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
                 [ #  # ]
    2462 [ #  # ][ #  # ]:          0 :     pBindings->GetDispatcher()->Execute( nColId, SFX_CALLMODE_RECORD, pColumnItem, &aFlag, 0L );
    2463                 :          0 : }
    2464                 :            : 
    2465                 :          0 : void SvxRuler::ApplyObject()
    2466                 :            : 
    2467                 :            : /* [Description]
    2468                 :            : 
    2469                 :            :    Applying object settings, changed by dragging.
    2470                 :            : */
    2471                 :            : {
    2472                 :            :     // to the page margin
    2473         [ #  # ]:          0 :     long nMargin = pLRSpaceItem? pLRSpaceItem->GetLeft(): 0;
    2474                 :            :     pObjectItem->SetStartX(
    2475                 :            :                            PixelAdjust(
    2476                 :          0 :                               ConvertPosLogic(pObjectBorders[0].nPos)
    2477                 :          0 :                               + nMargin - lAppNullOffset,pObjectItem->GetStartX()));
    2478                 :            :     pObjectItem->SetEndX(
    2479                 :            :                          PixelAdjust(
    2480                 :          0 :                              ConvertPosLogic(pObjectBorders[1].nPos)
    2481                 :          0 :                          + nMargin -  lAppNullOffset,pObjectItem->GetEndX()));
    2482         [ #  # ]:          0 :     nMargin = pULSpaceItem? pULSpaceItem->GetUpper(): 0;
    2483                 :            :     pObjectItem->SetStartY(
    2484                 :            :                          PixelAdjust(
    2485                 :          0 :                              ConvertPosLogic(pObjectBorders[2].nPos)
    2486                 :          0 :                            + nMargin - lAppNullOffset,pObjectItem->GetStartY()));
    2487                 :            :     pObjectItem->SetEndY(
    2488                 :            :                      PixelAdjust(
    2489                 :          0 :                          ConvertPosLogic(pObjectBorders[3].nPos)
    2490                 :          0 :                          + nMargin - lAppNullOffset,pObjectItem->GetEndY()));
    2491                 :          0 :     pBindings->GetDispatcher()->Execute( SID_RULER_OBJECT, SFX_CALLMODE_RECORD, pObjectItem, 0L );
    2492                 :          0 : }
    2493                 :            : 
    2494                 :          0 : void SvxRuler::PrepareProportional_Impl(RulerType eType)
    2495                 :            : 
    2496                 :            : /* [Description]
    2497                 :            : 
    2498                 :            :    Preparation proportional dragging, and it is calculated based on the
    2499                 :            :    proportional share of the total width in parts per thousand.
    2500                 :            : */
    2501                 :            : {
    2502                 :          0 :     pRuler_Imp->nTotalDist = GetMargin2();
    2503      [ #  #  # ]:          0 :     switch((int)eType)
    2504                 :            :     {
    2505                 :            :       case RULER_TYPE_MARGIN2:
    2506                 :            :       case RULER_TYPE_MARGIN1:
    2507                 :            :       case RULER_TYPE_BORDER:
    2508                 :            :         {
    2509                 :            :             DBG_ASSERT(pColumnItem, "no ColumnItem");
    2510                 :            : 
    2511                 :          0 :             pRuler_Imp->SetPercSize(pColumnItem->Count());
    2512                 :            : 
    2513                 :            :             long lPos;
    2514                 :          0 :             long lWidth=0;
    2515                 :            :             sal_uInt16 nStart;
    2516                 :          0 :             sal_uInt16 nIdx=GetDragAryPos();
    2517                 :          0 :             lWidth=0;
    2518                 :          0 :             long lActWidth=0;
    2519                 :            :             long lActBorderSum;
    2520                 :            :             long lOrigLPos;
    2521                 :            : 
    2522         [ #  # ]:          0 :             if(eType != RULER_TYPE_BORDER)
    2523                 :            :             {
    2524                 :          0 :                 lOrigLPos = GetMargin1();
    2525                 :          0 :                 nStart = 0;
    2526                 :          0 :                 lActBorderSum = 0;
    2527                 :            :             }
    2528                 :            :             else
    2529                 :            :             {
    2530 [ #  # ][ #  # ]:          0 :                 if(pRuler_Imp->bIsTableRows &&!bHorz)
    2531                 :            :                 {
    2532                 :          0 :                     lOrigLPos = GetMargin1();
    2533                 :          0 :                     nStart = 0;
    2534                 :            :                 }
    2535                 :            :                 else
    2536                 :            :                 {
    2537                 :          0 :                     lOrigLPos = pBorders[nIdx].nPos + pBorders[nIdx].nWidth;
    2538                 :          0 :                     nStart = 1;
    2539                 :            :                 }
    2540                 :          0 :                 lActBorderSum = pBorders[nIdx].nWidth;
    2541                 :            :             }
    2542                 :            : 
    2543                 :            :             //in horizontal mode the percentage value has to be
    2544                 :            :             //calculated on a "current change" position base
    2545                 :            :             //because the height of the table changes while dragging
    2546 [ #  # ][ #  # ]:          0 :             if(pRuler_Imp->bIsTableRows && RULER_TYPE_BORDER == eType)
    2547                 :            :             {
    2548                 :            :                 sal_uInt16 nStartBorder;
    2549                 :            :                 sal_uInt16 nEndBorder;
    2550         [ #  # ]:          0 :                 if(bHorz)
    2551                 :            :                 {
    2552                 :          0 :                     nStartBorder = nIdx + 1;
    2553                 :          0 :                     nEndBorder = pColumnItem->Count() - 1;
    2554                 :            :                 }
    2555                 :            :                 else
    2556                 :            :                 {
    2557                 :          0 :                     nStartBorder = 0;
    2558                 :          0 :                     nEndBorder = nIdx;
    2559                 :            :                 }
    2560                 :            : 
    2561                 :          0 :                 lWidth = pBorders[nIdx].nPos;
    2562         [ #  # ]:          0 :                 if(bHorz)
    2563                 :          0 :                     lWidth = GetMargin2() - lWidth;
    2564                 :          0 :                 pRuler_Imp->nTotalDist = lWidth;
    2565                 :          0 :                 lPos = lOrigLPos = pBorders[nIdx].nPos;
    2566                 :            : 
    2567         [ #  # ]:          0 :                 for(sal_uInt16 i = nStartBorder; i < nEndBorder; ++i)
    2568                 :            :                 {
    2569         [ #  # ]:          0 :                     if(bHorz)
    2570                 :            :                     {
    2571                 :          0 :                         lActWidth += pBorders[i].nPos - lPos;
    2572                 :          0 :                         lPos = pBorders[i].nPos + pBorders[i].nWidth;
    2573                 :            :                     }
    2574                 :            :                     else
    2575                 :          0 :                         lActWidth = pBorders[i].nPos;
    2576                 :          0 :                     pRuler_Imp->pPercBuf[i] = (sal_uInt16)((lActWidth * 1000)
    2577                 :          0 :                                                     / pRuler_Imp->nTotalDist);
    2578                 :          0 :                     pRuler_Imp->pBlockBuf[i] = (sal_uInt16)lActBorderSum;
    2579                 :          0 :                     lActBorderSum += pBorders[i].nWidth;
    2580                 :          0 :                 }
    2581                 :            :             }
    2582                 :            :             else
    2583                 :            :             {
    2584                 :          0 :                 lPos = lOrigLPos;
    2585         [ #  # ]:          0 :                 for(sal_uInt16 ii = nStart; ii < pColumnItem->Count() - 1; ++ii)
    2586                 :            :                 {
    2587                 :          0 :                     lWidth += pBorders[ii].nPos - lPos;
    2588                 :          0 :                     lPos = pBorders[ii].nPos + pBorders[ii].nWidth;
    2589                 :            :                 }
    2590                 :            : 
    2591                 :          0 :                 lWidth += GetMargin2() - lPos;
    2592                 :          0 :                 pRuler_Imp->nTotalDist = lWidth;
    2593                 :          0 :                 lPos = lOrigLPos;
    2594                 :            : 
    2595         [ #  # ]:          0 :                 for(sal_uInt16 i = nStart; i < pColumnItem->Count() - 1; ++i)
    2596                 :            :                 {
    2597                 :          0 :                     lActWidth += pBorders[i].nPos - lPos;
    2598                 :          0 :                     lPos = pBorders[i].nPos + pBorders[i].nWidth;
    2599                 :          0 :                     pRuler_Imp->pPercBuf[i] = (sal_uInt16)((lActWidth * 1000)
    2600                 :          0 :                                                     / pRuler_Imp->nTotalDist);
    2601                 :          0 :                     pRuler_Imp->pBlockBuf[i] = (sal_uInt16)lActBorderSum;
    2602                 :          0 :                     lActBorderSum += pBorders[i].nWidth;
    2603                 :            :                 }
    2604                 :            :             }
    2605                 :            :         }
    2606                 :          0 :         break;
    2607                 :            :         case RULER_TYPE_TAB:
    2608                 :            :         {
    2609                 :          0 :             const sal_uInt16 nIdx = GetDragAryPos()+TAB_GAP;
    2610                 :          0 :             pRuler_Imp->nTotalDist -= pTabs[nIdx].nPos;
    2611                 :          0 :             pRuler_Imp->SetPercSize(nTabCount);
    2612         [ #  # ]:          0 :             for(sal_uInt16 n=0;n<=nIdx;pRuler_Imp->pPercBuf[n++]=0) ;
    2613         [ #  # ]:          0 :             for(sal_uInt16 i = nIdx+1; i < nTabCount; ++i)
    2614                 :            :             {
    2615                 :          0 :                 const long nDelta = pTabs[i].nPos - pTabs[nIdx].nPos;
    2616                 :          0 :                 pRuler_Imp->pPercBuf[i] = (sal_uInt16)((nDelta * 1000) / pRuler_Imp->nTotalDist);
    2617                 :            :             }
    2618                 :          0 :             break;
    2619                 :            :         }
    2620                 :            :     }
    2621                 :          0 : }
    2622                 :            : 
    2623                 :            : 
    2624                 :          0 : void SvxRuler::EvalModifier()
    2625                 :            : 
    2626                 :            : /* [Description]
    2627                 :            : 
    2628                 :            :    Eval Drag Modifier
    2629                 :            : 
    2630                 :            :    Shift: move linear
    2631                 :            :    Control: move proportional
    2632                 :            :    Shift+Control: Table: only current line
    2633                 :            :    Alt: dimension arrows (not implemented) //!!
    2634                 :            : 
    2635                 :            : */
    2636                 :            : 
    2637                 :            : {
    2638                 :          0 :     sal_uInt16 nModifier = GetDragModifier();
    2639         [ #  # ]:          0 :     if(pRuler_Imp->bIsTableRows)
    2640                 :            :     {
    2641                 :            :         //rows can only be moved in one way, additionally current column is possible
    2642         [ #  # ]:          0 :         if(nModifier == KEY_SHIFT)
    2643                 :          0 :             nModifier = 0;
    2644                 :            :     }
    2645   [ #  #  #  # ]:          0 :     switch(nModifier)
    2646                 :            :     {
    2647                 :            :      case KEY_SHIFT:
    2648                 :          0 :         nDragType = DRAG_OBJECT_SIZE_LINEAR;
    2649                 :          0 :         break;
    2650                 :            :      case KEY_MOD1:  {
    2651                 :          0 :          const RulerType eType = GetDragType();
    2652                 :          0 :          nDragType = DRAG_OBJECT_SIZE_PROPORTIONAL;
    2653 [ #  # ][ #  # ]:          0 :          if( RULER_TYPE_TAB == eType ||
         [ #  # ][ #  # ]
                 [ #  # ]
    2654                 :            :              ( ( RULER_TYPE_BORDER == eType || RULER_TYPE_MARGIN1 == eType ||
    2655                 :            :                  RULER_TYPE_MARGIN2 == eType ) &&
    2656                 :            :                pColumnItem ) )
    2657                 :          0 :              PrepareProportional_Impl(eType);
    2658                 :          0 :          break;
    2659                 :            :      }
    2660                 :            :      case KEY_MOD1 | KEY_SHIFT:
    2661   [ #  #  #  # ]:          0 :         if(GetDragType()!=RULER_TYPE_MARGIN1&&
                 [ #  # ]
    2662                 :          0 :            GetDragType()!=RULER_TYPE_MARGIN2)
    2663                 :          0 :             nDragType = DRAG_OBJECT_ACTLINE_ONLY;
    2664                 :          0 :         break;
    2665                 :            :         // ALT: Dimension arrows
    2666                 :            :     }
    2667                 :          0 : }
    2668                 :            : 
    2669                 :            : 
    2670                 :          0 : void SvxRuler::Click()
    2671                 :            : 
    2672                 :            : /* [Description]
    2673                 :            : 
    2674                 :            :    Overloaded handler SV; sets Tab per dispatcher call
    2675                 :            : */
    2676                 :            : 
    2677                 :            : {
    2678                 :          0 :     Ruler::Click();
    2679         [ #  # ]:          0 :     if( bActive )
    2680                 :            :     {
    2681                 :          0 :         pBindings->Update( SID_RULER_LR_MIN_MAX );
    2682                 :          0 :         pBindings->Update( SID_ATTR_LONG_ULSPACE );
    2683                 :          0 :         pBindings->Update( SID_ATTR_LONG_LRSPACE );
    2684                 :          0 :         pBindings->Update( SID_RULER_PAGE_POS );
    2685         [ #  # ]:          0 :         pBindings->Update( bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL);
    2686         [ #  # ]:          0 :         pBindings->Update( bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL);
    2687         [ #  # ]:          0 :         pBindings->Update( bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
    2688         [ #  # ]:          0 :         pBindings->Update( bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL);
    2689                 :          0 :         pBindings->Update( SID_RULER_OBJECT );
    2690                 :          0 :         pBindings->Update( SID_RULER_PROTECT );
    2691                 :          0 :         pBindings->Update( SID_ATTR_PARA_LRSPACE_VERTICAL );
    2692                 :            :     }
    2693 [ #  # ][ #  # ]:          0 :     sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
    2694 [ #  # ][ #  # ]:          0 :     if(pTabStopItem &&
    2695                 :            :        (nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS)
    2696                 :            :     {
    2697                 :          0 :         sal_Bool bContentProtected = pRuler_Imp->aProtectItem.IsCntntProtected();
    2698         [ #  # ]:          0 :         if( bContentProtected ) return;
    2699                 :          0 :         const long lPos = GetClickPos();
    2700 [ #  # ][ #  # ]:          0 :         if((bRTL && lPos < Min(GetFirstLineIndent(), GetLeftIndent()) && lPos > GetRightIndent()) ||
           [ #  #  #  #  
           #  # ][ #  # ]
                 [ #  # ]
    2701                 :          0 :             (!bRTL && lPos > Min(GetFirstLineIndent(), GetLeftIndent()) && lPos < GetRightIndent()))
    2702                 :            :         {
    2703                 :            :             //convert position in left-to-right text
    2704                 :            :             long nTabPos;
    2705                 :            :     //#i24363# tab stops relative to indent
    2706         [ #  # ]:          0 :             if(bRTL)
    2707                 :            :                 nTabPos = ( pRuler_Imp->bIsTabsRelativeToIndent ?
    2708                 :            :                             GetLeftIndent() :
    2709         [ #  # ]:          0 :                             ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset ) ) -
    2710 [ #  # ][ #  # ]:          0 :                           lPos;
                 [ #  # ]
    2711                 :            :             else
    2712                 :            :                 nTabPos = lPos -
    2713                 :            :                           ( pRuler_Imp->bIsTabsRelativeToIndent ?
    2714                 :            :                             GetLeftIndent() :
    2715 [ #  # ][ #  # ]:          0 :                             0 );
    2716                 :            : 
    2717                 :            :             SvxTabStop aTabStop(ConvertHPosLogic(nTabPos),
    2718 [ #  # ][ #  # ]:          0 :                                 ToAttrTab_Impl(nDefTabType));
    2719         [ #  # ]:          0 :             pTabStopItem->Insert(aTabStop);
    2720         [ #  # ]:          0 :             UpdateTabs();
    2721                 :            :         }
    2722                 :            :     }
    2723                 :            : }
    2724                 :            : 
    2725                 :            : 
    2726                 :          0 : sal_Bool SvxRuler::CalcLimits
    2727                 :            : (
    2728                 :            :  long &nMax1,                                   // minimum value to be set
    2729                 :            :  long &nMax2,                                   // minimum value to be set
    2730                 :            :  sal_Bool
    2731                 :            : ) const
    2732                 :            : 
    2733                 :            : /* [Description]
    2734                 :            : 
    2735                 :            :    Default implementation of the virtual function; the application can be
    2736                 :            :    overloaded to implement customized limits. The values are based on the page.
    2737                 :            : */
    2738                 :            : {
    2739                 :          0 :     nMax1 = LONG_MIN;
    2740                 :          0 :     nMax2 = LONG_MAX;
    2741                 :          0 :     return sal_False;
    2742                 :            : }
    2743                 :            : 
    2744                 :            : 
    2745                 :          0 : void SvxRuler::CalcMinMax()
    2746                 :            : 
    2747                 :            : /* [Description]
    2748                 :            : 
    2749                 :            :    Calculates the limits for dragging; which are in pixels relative to the
    2750                 :            :    page edge
    2751                 :            : */
    2752                 :            : 
    2753                 :            : {
    2754 [ #  # ][ #  # ]:          0 :     sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
    2755                 :          0 :     const long lNullPix = ConvertPosPixel(lLogicNullOffset);
    2756                 :          0 :     pRuler_Imp->lMaxLeftLogic=pRuler_Imp->lMaxRightLogic=-1;
    2757   [ #  #  #  #  :          0 :     switch(GetDragType())
                   #  # ]
    2758                 :            :     {
    2759                 :            :       case RULER_TYPE_MARGIN1:
    2760                 :            :         {        // left edge of the surrounding Frame
    2761                 :            :             // DragPos - NOf between left - right
    2762                 :          0 :             pRuler_Imp->lMaxLeftLogic = GetLeftMin();
    2763                 :          0 :             nMaxLeft=ConvertSizePixel(pRuler_Imp->lMaxLeftLogic);
    2764                 :            : 
    2765 [ #  # ][ #  # ]:          0 :             if(!pColumnItem || pColumnItem->Count() == 1 )
                 [ #  # ]
    2766                 :            :             {
    2767         [ #  # ]:          0 :                 if(bRTL)
    2768                 :            :                 {
    2769                 :          0 :                     nMaxRight = lNullPix - GetRightIndent() +
    2770                 :          0 :                         Max(GetFirstLineIndent(), GetLeftIndent()) -
    2771                 :          0 :                         lMinFrame;
    2772                 :            :                 }
    2773                 :            :                 else
    2774                 :            :                 {
    2775                 :          0 :                     nMaxRight = lNullPix + GetRightIndent() -
    2776                 :          0 :                         Max(GetFirstLineIndent(), GetLeftIndent()) -
    2777                 :          0 :                         lMinFrame;
    2778                 :            :                 }
    2779                 :            :             }
    2780         [ #  # ]:          0 :             else if(pRuler_Imp->bIsTableRows)
    2781                 :            :             {
    2782                 :            :                 //top border is not moveable when table rows are displayed
    2783                 :            :                 // protection of content means the margin is not moveable
    2784                 :            :                 // - it's just a page break inside of a cell
    2785 [ #  # ][ #  # ]:          0 :                 if(bHorz && !pRuler_Imp->aProtectItem.IsCntntProtected())
                 [ #  # ]
    2786                 :            :                 {
    2787                 :          0 :                     nMaxLeft = pBorders[0].nMinPos + lNullPix;
    2788         [ #  # ]:          0 :                     if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
    2789                 :          0 :                         nMaxRight = GetRightIndent() + lNullPix -
    2790                 :          0 :                                 (pColumnItem->Count() - 1 ) * lMinFrame;
    2791                 :            :                     else
    2792                 :          0 :                         nMaxRight = pBorders[0].nPos - lMinFrame + lNullPix;
    2793                 :            :                 }
    2794                 :            :                 else
    2795                 :          0 :                     nMaxLeft = nMaxRight = lNullPix;
    2796                 :            :             }
    2797                 :            :             else
    2798                 :            :             {
    2799         [ #  # ]:          0 :                 if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
    2800                 :            :                 {
    2801                 :          0 :                     nMaxRight=lNullPix+CalcPropMaxRight();
    2802                 :            :                 }
    2803         [ #  # ]:          0 :                 else if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
    2804                 :            :                 {
    2805                 :            :                     nMaxRight = ConvertPosPixel(
    2806                 :          0 :                         GetPageWidth() - (
    2807                 :          0 :                             (pColumnItem->IsTable() && pLRSpaceItem)
    2808 [ #  # ][ #  # ]:          0 :                             ? pLRSpaceItem->GetRight() : 0))
    2809                 :          0 :                             - GetMargin2() + GetMargin1();
    2810                 :            :                 }
    2811                 :            :                 else
    2812                 :            :                 {
    2813                 :          0 :                     nMaxRight = lNullPix - lMinFrame;
    2814         [ #  # ]:          0 :                     if(pColumnItem->IsFirstAct())
    2815                 :            :                     {
    2816         [ #  # ]:          0 :                         if(bRTL)
    2817                 :            :                         {
    2818                 :            :                             nMaxRight += Min(
    2819                 :          0 :                                 pBorders[0].nPos,
    2820                 :          0 :                                 Max(GetFirstLineIndent(), GetLeftIndent()) - GetRightIndent());
    2821                 :            :                         }
    2822                 :            :                         else
    2823                 :            :                         {
    2824                 :            :                             nMaxRight += Min(
    2825                 :          0 :                                 pBorders[0].nPos, GetRightIndent() -
    2826                 :          0 :                                 Max(GetFirstLineIndent(), GetLeftIndent()));
    2827                 :            :                         }
    2828                 :            :                     }
    2829         [ #  # ]:          0 :                     else if( pColumnItem->Count() > 1 )
    2830                 :          0 :                         nMaxRight += pBorders[0].nPos;
    2831                 :            :                     else
    2832                 :          0 :                         nMaxRight +=GetRightIndent() -
    2833                 :          0 :                             Max(GetFirstLineIndent(), GetLeftIndent());
    2834                 :            :                     // Do not drag the left table edge over the edge of the page
    2835 [ #  # ][ #  # ]:          0 :                     if(pLRSpaceItem&&pColumnItem->IsTable())
                 [ #  # ]
    2836                 :            :                     {
    2837                 :          0 :                         long nTmp=ConvertSizePixel(pLRSpaceItem->GetLeft());
    2838         [ #  # ]:          0 :                         if(nTmp>nMaxLeft)
    2839                 :          0 :                             nMaxLeft=nTmp;
    2840                 :            :                     }
    2841                 :            :                 }
    2842                 :            :             }
    2843                 :          0 :             break;
    2844                 :            :         }
    2845                 :            :       case RULER_TYPE_MARGIN2:
    2846                 :            :      {        // right edge of the surrounding Frame
    2847                 :            :         pRuler_Imp->lMaxRightLogic =
    2848                 :            :             pMinMaxItem ?
    2849         [ #  # ]:          0 :                 GetPageWidth() - GetRightMax() : GetPageWidth();
    2850                 :          0 :         nMaxRight = ConvertSizePixel(pRuler_Imp->lMaxRightLogic);
    2851                 :            : 
    2852                 :            : 
    2853         [ #  # ]:          0 :         if(!pColumnItem)
    2854                 :            :         {
    2855         [ #  # ]:          0 :             if(bRTL)
    2856                 :            :             {
    2857                 :          0 :                 nMaxLeft =  GetMargin2() + GetRightIndent() -
    2858                 :          0 :                     Max(GetFirstLineIndent(),GetLeftIndent())  - GetMargin1()+
    2859                 :          0 :                         lMinFrame + lNullPix;
    2860                 :            :             }
    2861                 :            :             else
    2862                 :            :             {
    2863                 :          0 :                 nMaxLeft =  GetMargin2() - GetRightIndent() +
    2864                 :          0 :                     Max(GetFirstLineIndent(),GetLeftIndent())  - GetMargin1()+
    2865                 :          0 :                         lMinFrame + lNullPix;
    2866                 :            :             }
    2867                 :            :         }
    2868         [ #  # ]:          0 :         else if(pRuler_Imp->bIsTableRows)
    2869                 :            :         {
    2870                 :            :             // get the bottom move range from the last border position - only available for rows!
    2871                 :            :             // protection of content means the margin is not moveable - it's just a page break inside of a cell
    2872 [ #  # ][ #  # ]:          0 :             if(bHorz || pRuler_Imp->aProtectItem.IsCntntProtected())
                 [ #  # ]
    2873                 :            :             {
    2874                 :          0 :                 nMaxLeft = nMaxRight = pBorders[pColumnItem->Count() - 1].nMaxPos + lNullPix;
    2875                 :            :             }
    2876                 :            :             else
    2877                 :            :             {
    2878         [ #  # ]:          0 :                 if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
    2879                 :            :                 {
    2880                 :          0 :                     nMaxLeft = (pColumnItem->Count()) * lMinFrame + lNullPix;
    2881                 :            :                 }
    2882                 :            :                 else
    2883                 :            :                 {
    2884         [ #  # ]:          0 :                     if(pColumnItem->Count() > 1)
    2885                 :          0 :                         nMaxLeft = pBorders[pColumnItem->Count() - 2].nPos + lMinFrame + lNullPix;
    2886                 :            :                     else
    2887                 :          0 :                         nMaxLeft = lMinFrame + lNullPix;
    2888                 :            :                 }
    2889         [ #  # ]:          0 :                 if(pColumnItem->Count() > 1)
    2890                 :          0 :                     nMaxRight = pBorders[pColumnItem->Count() - 2].nMaxPos + lNullPix;
    2891                 :            :                 else
    2892                 :          0 :                     nMaxRight -= GetRightIndent() - lNullPix;
    2893                 :            :             }
    2894                 :            :         }
    2895                 :            :         else
    2896                 :            :         {
    2897                 :          0 :             nMaxLeft = lMinFrame + lNullPix;
    2898 [ #  # ][ #  # ]:          0 :             if(IsActLastColumn() || pColumnItem->Count() < 2 ) //If last active column
                 [ #  # ]
    2899                 :            :             {
    2900         [ #  # ]:          0 :                 if(bRTL)
    2901                 :            :                 {
    2902                 :          0 :                     nMaxLeft = lMinFrame + lNullPix + GetMargin2() +
    2903                 :          0 :                         GetRightIndent() - Max(GetFirstLineIndent(),
    2904                 :          0 :                                                GetLeftIndent());
    2905                 :            :                 }
    2906                 :            :                 else
    2907                 :            :                 {
    2908                 :          0 :                     nMaxLeft = lMinFrame + lNullPix + GetMargin2() -
    2909                 :          0 :                         GetRightIndent() + Max(GetFirstLineIndent(),
    2910                 :          0 :                                                GetLeftIndent());
    2911                 :            :                 }
    2912                 :            :             }
    2913         [ #  # ]:          0 :             if( pColumnItem->Count() >= 2 )
    2914                 :            :             {
    2915                 :            :                 long nNewMaxLeft =
    2916                 :            :                     lMinFrame + lNullPix +
    2917                 :          0 :                     pBorders[pColumnItem->Count()-2].nPos +
    2918                 :          0 :                     pBorders[pColumnItem->Count()-2].nWidth;
    2919                 :          0 :                 nMaxLeft=Max(nMaxLeft,nNewMaxLeft);
    2920                 :            :             }
    2921                 :            : 
    2922                 :            :         }
    2923                 :          0 :         break;
    2924                 :            :     }
    2925                 :            :     case RULER_TYPE_BORDER:
    2926                 :            :     {                // Table, column (Modifier)
    2927                 :          0 :         const sal_uInt16 nIdx = GetDragAryPos();
    2928   [ #  #  #  # ]:          0 :         switch(GetDragSize())
    2929                 :            :         {
    2930                 :            :           case RULER_DRAGSIZE_1 :
    2931                 :            :             {
    2932                 :          0 :                 nMaxRight = pBorders[nIdx].nPos +
    2933                 :          0 :                     pBorders[nIdx].nWidth + lNullPix;
    2934                 :            : 
    2935         [ #  # ]:          0 :                 if(0 == nIdx)
    2936                 :          0 :                     nMaxLeft = lNullPix;
    2937                 :            :                 else
    2938                 :          0 :                     nMaxLeft = pBorders[nIdx-1].nPos +
    2939                 :          0 :                         pBorders[nIdx-1].nWidth + lNullPix;
    2940         [ #  # ]:          0 :                 if(nIdx == pColumnItem->GetActColumn())
    2941                 :            :                 {
    2942         [ #  # ]:          0 :                     if(bRTL)
    2943                 :            :                     {
    2944                 :          0 :                         nMaxLeft += pBorders[nIdx].nPos +
    2945                 :          0 :                             GetRightIndent() - Max(GetFirstLineIndent(),
    2946                 :          0 :                                                    GetLeftIndent());
    2947                 :            :                     }
    2948                 :            :                     else
    2949                 :            :                     {
    2950                 :          0 :                         nMaxLeft += pBorders[nIdx].nPos -
    2951                 :          0 :                             GetRightIndent() + Max(GetFirstLineIndent(),
    2952                 :          0 :                                                    GetLeftIndent());
    2953                 :            :                     }
    2954         [ #  # ]:          0 :                     if(0 != nIdx)
    2955                 :          0 :                         nMaxLeft -= pBorders[nIdx-1].nPos +
    2956                 :          0 :                             pBorders[nIdx-1].nWidth;
    2957                 :            :                 }
    2958                 :          0 :                 nMaxLeft += lMinFrame;
    2959                 :          0 :                 nMaxLeft += nDragOffset;
    2960                 :          0 :                 break;
    2961                 :            :             }
    2962                 :            :           case RULER_DRAGSIZE_MOVE:
    2963                 :            :             {
    2964         [ #  # ]:          0 :                 if(pColumnItem)
    2965                 :            :                 {
    2966                 :            :                     //nIdx contains the position of the currently moved item
    2967                 :            :                     //next visible separator on the left
    2968                 :          0 :                     sal_uInt16 nLeftCol=GetActLeftColumn(sal_False, nIdx);
    2969                 :            :                     //next visible separator on the right
    2970                 :          0 :                     sal_uInt16 nRightCol=GetActRightColumn(sal_False, nIdx);
    2971                 :            :                     //next separator on the left - regardless if visible or not
    2972                 :          0 :                     sal_uInt16 nActLeftCol=GetActLeftColumn();
    2973                 :            :                     //next separator on the right - regardless if visible or not
    2974                 :          0 :                     sal_uInt16 nActRightCol=GetActRightColumn();
    2975         [ #  # ]:          0 :                     if(pColumnItem->IsTable())
    2976                 :            :                     {
    2977         [ #  # ]:          0 :                         if(nDragType & DRAG_OBJECT_ACTLINE_ONLY)
    2978                 :            :                         {
    2979                 :            :                             //the current row/column should be modified only
    2980                 :            :                             //then the next/previous visible border position
    2981                 :            :                             //marks the min/max positions
    2982                 :            :                             nMaxLeft = nLeftCol == USHRT_MAX ?
    2983                 :            :                                 0 :
    2984         [ #  # ]:          0 :                                 pBorders[nLeftCol].nPos;
    2985                 :            :                             //rows can always be increased without a limit
    2986         [ #  # ]:          0 :                             if(pRuler_Imp->bIsTableRows)
    2987                 :          0 :                                 nMaxRight = pBorders[nIdx].nMaxPos;
    2988                 :            :                             else
    2989                 :            :                                 nMaxRight = nRightCol == USHRT_MAX ?
    2990                 :          0 :                                     GetMargin2():
    2991         [ #  # ]:          0 :                                     pBorders[nRightCol].nPos;
    2992                 :          0 :                             nMaxLeft += lNullPix;
    2993                 :          0 :                             nMaxRight += lNullPix;
    2994                 :            :                         }
    2995                 :            :                         else
    2996                 :            :                         {
    2997 [ #  # ][ #  # ]:          0 :                             if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType && !bHorz && pRuler_Imp->bIsTableRows)
                 [ #  # ]
    2998                 :          0 :                                 nMaxLeft = (nIdx + 1) * lMinFrame + lNullPix;
    2999                 :            :                             else
    3000                 :          0 :                                 nMaxLeft = pBorders[nIdx].nMinPos + lNullPix;
    3001 [ #  # ][ #  # ]:          0 :                             if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType||
    3002                 :            :                             (DRAG_OBJECT_SIZE_LINEAR & nDragType) )
    3003                 :            :                             {
    3004         [ #  # ]:          0 :                                 if(pRuler_Imp->bIsTableRows)
    3005                 :            :                                 {
    3006         [ #  # ]:          0 :                                     if(bHorz)
    3007                 :          0 :                                         nMaxRight = GetRightIndent() + lNullPix -
    3008                 :          0 :                                                 (pColumnItem->Count() - nIdx - 1) * lMinFrame;
    3009                 :            :                                     else
    3010                 :          0 :                                         nMaxRight = pBorders[nIdx].nMaxPos + lNullPix;
    3011                 :            :                                 }
    3012                 :            :                                 else
    3013                 :          0 :                                     nMaxRight=lNullPix+CalcPropMaxRight(nIdx);
    3014                 :            :                             }
    3015                 :            :                             else
    3016                 :          0 :                                 nMaxRight = pBorders[nIdx].nMaxPos + lNullPix;
    3017                 :            :                         }
    3018                 :          0 :                         nMaxLeft += lMinFrame;
    3019                 :          0 :                         nMaxRight -= lMinFrame;
    3020                 :            : 
    3021                 :            :                     }
    3022                 :            :                     else
    3023                 :            :                     {
    3024         [ #  # ]:          0 :                         if(nLeftCol==USHRT_MAX)
    3025                 :          0 :                             nMaxLeft=lNullPix;
    3026                 :            :                         else
    3027                 :          0 :                             nMaxLeft = pBorders[nLeftCol].nPos +
    3028                 :          0 :                                 pBorders[nLeftCol].nWidth + lNullPix;
    3029                 :            : 
    3030         [ #  # ]:          0 :                         if(nActRightCol == nIdx)
    3031                 :            :                         {
    3032         [ #  # ]:          0 :                             if(bRTL)
    3033                 :            :                             {
    3034                 :          0 :                                 nMaxLeft += pBorders[nIdx].nPos +
    3035                 :          0 :                                     GetRightIndent() - Max(GetFirstLineIndent(),
    3036                 :          0 :                                                            GetLeftIndent());
    3037         [ #  # ]:          0 :                                 if(nActLeftCol!=USHRT_MAX)
    3038                 :          0 :                                     nMaxLeft -= pBorders[nActLeftCol].nPos +
    3039                 :          0 :                                         pBorders[nActLeftCol].nWidth;
    3040                 :            :                             }
    3041                 :            :                             else
    3042                 :            :                             {
    3043                 :          0 :                                 nMaxLeft += pBorders[nIdx].nPos -
    3044                 :          0 :                                     GetRightIndent() + Max(GetFirstLineIndent(),
    3045                 :          0 :                                                            GetLeftIndent());
    3046         [ #  # ]:          0 :                                 if(nActLeftCol!=USHRT_MAX)
    3047                 :          0 :                                     nMaxLeft -= pBorders[nActLeftCol].nPos +
    3048                 :          0 :                                         pBorders[nActLeftCol].nWidth;
    3049                 :            :                             }
    3050                 :            :                         }
    3051                 :          0 :                         nMaxLeft += lMinFrame;
    3052                 :          0 :                         nMaxLeft += nDragOffset;
    3053                 :            : 
    3054                 :            :                         // nMaxRight
    3055                 :            :                         // linear / proprotional move
    3056 [ #  # ][ #  # ]:          0 :                         if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType||
    3057                 :            :                            (DRAG_OBJECT_SIZE_LINEAR & nDragType) )
    3058                 :            :                         {
    3059                 :          0 :                             nMaxRight=lNullPix+CalcPropMaxRight(nIdx);
    3060                 :            :                         }
    3061         [ #  # ]:          0 :                         else if(DRAG_OBJECT_SIZE_LINEAR & nDragType)
    3062                 :            :                         {
    3063                 :          0 :                             nMaxRight=lNullPix+GetMargin2()-GetMargin1()+
    3064                 :          0 :                                 (nBorderCount-nIdx-1)*lMinFrame;
    3065                 :            :                         }
    3066                 :            :                         else
    3067                 :            :                         {
    3068         [ #  # ]:          0 :                             if(nRightCol==USHRT_MAX)
    3069                 :            :                             { // last column
    3070                 :          0 :                                 nMaxRight = GetMargin2() + lNullPix;
    3071         [ #  # ]:          0 :                                 if(IsActLastColumn())
    3072                 :            :                                 {
    3073         [ #  # ]:          0 :                                     if(bRTL)
    3074                 :            :                                     {
    3075                 :            :                                         nMaxRight -=
    3076                 :          0 :                                             GetMargin2() + GetRightIndent() -
    3077                 :            :                                                 Max(GetFirstLineIndent(),
    3078                 :          0 :                                                     GetLeftIndent());
    3079                 :            :                                     }
    3080                 :            :                                     else
    3081                 :            :                                     {
    3082                 :            :                                         nMaxRight -=
    3083                 :          0 :                                             GetMargin2() - GetRightIndent() +
    3084                 :            :                                                 Max(GetFirstLineIndent(),
    3085                 :          0 :                                                     GetLeftIndent());
    3086                 :            :                                     }
    3087                 :          0 :                                     nMaxRight += pBorders[nIdx].nPos +
    3088                 :          0 :                                         pBorders[nIdx].nWidth;
    3089                 :            :                                 }
    3090                 :            :                             }
    3091                 :            :                             else
    3092                 :            :                             {
    3093                 :          0 :                                 nMaxRight = lNullPix + pBorders[nRightCol].nPos;
    3094                 :            :                                 sal_uInt16 nNotHiddenRightCol =
    3095                 :          0 :                                     GetActRightColumn(sal_True, nIdx);
    3096                 :            : 
    3097         [ #  # ]:          0 :                                 if( nActLeftCol == nIdx )
    3098                 :            :                                 {
    3099                 :            :                                     long nBorder = nNotHiddenRightCol ==
    3100                 :            :                                         USHRT_MAX ?
    3101                 :          0 :                                         GetMargin2() :
    3102         [ #  # ]:          0 :                                         pBorders[nNotHiddenRightCol].nPos;
    3103         [ #  # ]:          0 :                                     if(bRTL)
    3104                 :            :                                     {
    3105                 :          0 :                                         nMaxRight -= nBorder + GetRightIndent() -
    3106                 :            :                                             Max(GetFirstLineIndent(),
    3107                 :          0 :                                                 GetLeftIndent());
    3108                 :            :                                     }
    3109                 :            :                                     else
    3110                 :            :                                     {
    3111                 :          0 :                                         nMaxRight -= nBorder - GetRightIndent() +
    3112                 :            :                                             Max(GetFirstLineIndent(),
    3113                 :          0 :                                                 GetLeftIndent());
    3114                 :            :                                     }
    3115                 :          0 :                                     nMaxRight += pBorders[nIdx].nPos +
    3116                 :          0 :                                         pBorders[nIdx].nWidth;
    3117                 :            :                                 }
    3118                 :            :                             }
    3119                 :          0 :                             nMaxRight -= lMinFrame;
    3120                 :          0 :                             nMaxRight -= pBorders[nIdx].nWidth;
    3121                 :            :                         }
    3122                 :            :                     }
    3123                 :            :                 }
    3124                 :            :                 // ObjectItem
    3125                 :            :                 else
    3126                 :            :                 {
    3127         [ #  # ]:          0 :                     if(pObjectItem->HasLimits())
    3128                 :            :                     {
    3129         [ #  # ]:          0 :                         if(CalcLimits(nMaxLeft, nMaxRight, nIdx & 1? sal_False : sal_True))
    3130                 :            :                         {
    3131                 :          0 :                             nMaxLeft = ConvertPosPixel(nMaxLeft);
    3132                 :          0 :                             nMaxRight = ConvertPosPixel(nMaxRight);
    3133                 :            :                         }
    3134                 :            :                     }
    3135                 :            :                     else
    3136                 :            :                     {
    3137                 :          0 :                         nMaxLeft = LONG_MIN;
    3138                 :          0 :                         nMaxRight = LONG_MAX;
    3139                 :            :                     }
    3140                 :            :                 }
    3141                 :          0 :                 break;
    3142                 :            :             }
    3143                 :            :           case RULER_DRAGSIZE_2:
    3144                 :            :             {
    3145                 :          0 :                 nMaxLeft = lNullPix + pBorders[nIdx].nPos;
    3146         [ #  # ]:          0 :                 if(nIdx == pColumnItem->Count()-2) { // last column
    3147                 :          0 :                     nMaxRight = GetMargin2() + lNullPix;
    3148         [ #  # ]:          0 :                     if(pColumnItem->IsLastAct()) {
    3149                 :            :                         nMaxRight -=
    3150                 :          0 :                             GetMargin2() - GetRightIndent() +
    3151                 :            :                                 Max(GetFirstLineIndent(),
    3152                 :          0 :                                     GetLeftIndent());
    3153                 :          0 :                         nMaxRight += pBorders[nIdx].nPos +
    3154                 :          0 :                             pBorders[nIdx].nWidth;
    3155                 :            :                     }
    3156                 :            :                 }
    3157                 :            :                 else {
    3158                 :          0 :                     nMaxRight = lNullPix + pBorders[nIdx+1].nPos;
    3159         [ #  # ]:          0 :                     if(pColumnItem->GetActColumn()-1 == nIdx) {
    3160                 :          0 :                         nMaxRight -= pBorders[nIdx+1].nPos  - GetRightIndent() +
    3161                 :            :                             Max(GetFirstLineIndent(),
    3162                 :          0 :                                 GetLeftIndent());
    3163                 :          0 :                         nMaxRight += pBorders[nIdx].nPos +
    3164                 :          0 :                             pBorders[nIdx].nWidth;
    3165                 :            :                     }
    3166                 :            :             }
    3167                 :          0 :                 nMaxRight -= lMinFrame;
    3168                 :          0 :                 nMaxRight -= pBorders[nIdx].nWidth;
    3169                 :          0 :                 break;
    3170                 :            :             }
    3171                 :            :         }
    3172                 :          0 :         nMaxRight += nDragOffset;
    3173                 :          0 :         break;
    3174                 :            :     }
    3175                 :            :       case RULER_TYPE_INDENT:
    3176                 :            :         {
    3177                 :          0 :         const sal_uInt16 nIdx = GetDragAryPos();
    3178      [ #  #  # ]:          0 :         switch(nIdx) {
    3179                 :            :         case INDENT_FIRST_LINE - INDENT_GAP:
    3180                 :            :         case INDENT_LEFT_MARGIN - INDENT_GAP:
    3181                 :            :             {
    3182         [ #  # ]:          0 :                 if(bRTL)
    3183                 :            :                 {
    3184                 :          0 :                     nMaxLeft = lNullPix + GetRightIndent();
    3185                 :            : 
    3186 [ #  # ][ #  # ]:          0 :                     if(pColumnItem && !pColumnItem->IsFirstAct())
                 [ #  # ]
    3187                 :          0 :                         nMaxLeft += pBorders[pColumnItem->GetActColumn()-1].nPos +
    3188                 :          0 :                             pBorders[pColumnItem->GetActColumn()-1].nWidth;
    3189                 :          0 :                     nMaxRight = lNullPix + GetMargin2();
    3190                 :            : 
    3191                 :            :                     // Dragging along
    3192 [ #  # ][ #  # ]:          0 :                     if((INDENT_FIRST_LINE - INDENT_GAP) != nIdx &&
    3193                 :            :                        (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
    3194                 :            :                        DRAG_OBJECT_LEFT_INDENT_ONLY)
    3195                 :            :                     {
    3196         [ #  # ]:          0 :                         if(GetLeftIndent() > GetFirstLineIndent())
    3197                 :          0 :                             nMaxLeft += GetLeftIndent() - GetFirstLineIndent();
    3198                 :            :                         else
    3199                 :          0 :                             nMaxRight -= GetFirstLineIndent() - GetLeftIndent();
    3200                 :            :                     }
    3201                 :            :                 }
    3202                 :            :                 else
    3203                 :            :                 {
    3204                 :          0 :                     nMaxLeft = lNullPix;
    3205                 :            : 
    3206 [ #  # ][ #  # ]:          0 :                     if(pColumnItem && !pColumnItem->IsFirstAct())
                 [ #  # ]
    3207                 :          0 :                         nMaxLeft += pBorders[pColumnItem->GetActColumn()-1].nPos +
    3208                 :          0 :                             pBorders[pColumnItem->GetActColumn()-1].nWidth;
    3209                 :          0 :                     nMaxRight = lNullPix + GetRightIndent() - lMinFrame;
    3210                 :            : 
    3211                 :            :                     // Dragging along
    3212 [ #  # ][ #  # ]:          0 :                     if((INDENT_FIRST_LINE - INDENT_GAP) != nIdx &&
    3213                 :            :                        (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
    3214                 :            :                        DRAG_OBJECT_LEFT_INDENT_ONLY)
    3215                 :            :                     {
    3216         [ #  # ]:          0 :                         if(GetLeftIndent() > GetFirstLineIndent())
    3217                 :          0 :                             nMaxLeft += GetLeftIndent() - GetFirstLineIndent();
    3218                 :            :                         else
    3219                 :          0 :                             nMaxRight -= GetFirstLineIndent() - GetLeftIndent();
    3220                 :            :                     }
    3221                 :            :                 }
    3222                 :            :             }
    3223                 :          0 :           break;
    3224                 :            :           case INDENT_RIGHT_MARGIN - INDENT_GAP:
    3225                 :            :             {
    3226         [ #  # ]:          0 :                 if(bRTL)
    3227                 :            :                 {
    3228                 :          0 :                     nMaxLeft = lNullPix;
    3229                 :          0 :                     nMaxRight = lNullPix + Min(GetFirstLineIndent(), GetLeftIndent()) - lMinFrame;
    3230         [ #  # ]:          0 :                     if(pColumnItem)
    3231                 :            :                     {
    3232                 :          0 :                         sal_uInt16 nRightCol=GetActRightColumn( sal_True );
    3233         [ #  # ]:          0 :                         if(!IsActLastColumn( sal_True ))
    3234                 :          0 :                             nMaxRight += pBorders[nRightCol].nPos;
    3235                 :            :                         else
    3236                 :          0 :                             nMaxRight += GetMargin2();
    3237                 :            :                     }
    3238                 :            :                     else
    3239                 :          0 :                         nMaxLeft += GetMargin1();
    3240                 :          0 :                     nMaxLeft += lMinFrame;
    3241                 :            :                 }
    3242                 :            :                 else
    3243                 :            :                 {
    3244                 :            :                     nMaxLeft = lNullPix +
    3245                 :          0 :                         Max(GetFirstLineIndent(), GetLeftIndent());
    3246                 :          0 :                     nMaxRight = lNullPix;
    3247         [ #  # ]:          0 :                     if(pColumnItem)
    3248                 :            :                     {
    3249                 :          0 :                         sal_uInt16 nRightCol=GetActRightColumn( sal_True );
    3250         [ #  # ]:          0 :                         if(!IsActLastColumn( sal_True ))
    3251                 :          0 :                             nMaxRight += pBorders[nRightCol].nPos;
    3252                 :            :                         else
    3253                 :          0 :                             nMaxRight += GetMargin2();
    3254                 :            :                     }
    3255                 :            :                     else
    3256                 :          0 :                         nMaxRight += GetMargin2();
    3257                 :          0 :                     nMaxLeft += lMinFrame;
    3258                 :            :                 }
    3259                 :            :             }
    3260                 :          0 :             break;
    3261                 :            :         }
    3262                 :          0 :         break;
    3263                 :            :     }
    3264                 :            :     case RULER_TYPE_TAB:                // Tabs (Modifier)
    3265                 :            :         /*
    3266                 :            :            left = NOf + Max(LAR, EZ)
    3267                 :            :            right = NOf + RAR
    3268                 :            :            */
    3269                 :          0 :         nMaxLeft = bRTL ? lNullPix + GetRightIndent()
    3270         [ #  # ]:          0 :                             : lNullPix + Min(GetFirstLineIndent(), GetLeftIndent());
    3271                 :          0 :         pRuler_Imp->lMaxRightLogic=GetLogicRightIndent()+lLogicNullOffset;
    3272                 :          0 :         nMaxRight = ConvertSizePixel(pRuler_Imp->lMaxRightLogic);
    3273                 :          0 :         break;
    3274                 :            :     default: ; //prevent warning
    3275                 :            :     }
    3276                 :            : #ifdef DEBUGLIN
    3277                 :            :     {
    3278                 :            :         String aStr("MinLeft: ");
    3279                 :            :         Size aSize(nMaxLeft + lNullPix, 0);
    3280                 :            :         Size aSize2(nMaxRight + lNullPix, 0);
    3281                 :            :         aSize = pEditWin->PixelToLogic(aSize, MapMode(MAP_MM));
    3282                 :            :         aSize2 = pEditWin->PixelToLogic(aSize2, MapMode(MAP_MM));
    3283                 :            :         aStr += String(aSize.Width());
    3284                 :            :         aStr += " MaxRight: ";
    3285                 :            :         aStr += String(aSize2.Width());
    3286                 :            :         InfoBox(0, aStr).Execute();
    3287                 :            :     }
    3288                 :            : #endif
    3289                 :          0 : }
    3290                 :            : 
    3291                 :            : 
    3292                 :          0 : long SvxRuler::StartDrag()
    3293                 :            : 
    3294                 :            : /* [Description]
    3295                 :            : 
    3296                 :            :    Beginning of a drag operation (SV-handler) evaluates modifier and
    3297                 :            :    calculated values
    3298                 :            : 
    3299                 :            :    [Cross-reference]
    3300                 :            : 
    3301                 :            :    <SvxRuler::EvalModifier()>
    3302                 :            :    <SvxRuler::CalcMinMax()>
    3303                 :            :    <SvxRuler::EndDrag()>
    3304                 :            : */
    3305                 :            : 
    3306                 :            : {
    3307                 :          0 :     sal_Bool bContentProtected = pRuler_Imp->aProtectItem.IsCntntProtected();
    3308         [ #  # ]:          0 :     if(!bValid)
    3309                 :          0 :         return sal_False;
    3310                 :            : 
    3311                 :          0 :     pRuler_Imp->lLastLMargin=GetMargin1();
    3312                 :          0 :     pRuler_Imp->lLastRMargin=GetMargin2();
    3313                 :          0 :     long bOk = 1;
    3314         [ #  # ]:          0 :     if(GetStartDragHdl().IsSet())
    3315                 :          0 :         bOk = Ruler::StartDrag();
    3316         [ #  # ]:          0 :     if(bOk) {
    3317                 :          0 :         lInitialDragPos = GetDragPos();
    3318   [ #  #  #  #  :          0 :         switch(GetDragType()) {
                      # ]
    3319                 :            :         case RULER_TYPE_MARGIN1:        // left edge of the surrounding Frame
    3320                 :            :         case RULER_TYPE_MARGIN2:        // right edge of the surrounding Frame
    3321 [ #  # ][ #  # ]:          0 :             if((bHorz && pLRSpaceItem) || (!bHorz && pULSpaceItem))
         [ #  # ][ #  # ]
    3322                 :            :             {
    3323         [ #  # ]:          0 :                 if(pColumnItem)
    3324                 :          0 :                     EvalModifier();
    3325                 :            :                 else
    3326                 :          0 :                     nDragType = DRAG_OBJECT;
    3327                 :            :             }
    3328                 :            :             else
    3329                 :          0 :                 bOk = sal_False;
    3330                 :          0 :             break;
    3331                 :            :         case RULER_TYPE_BORDER:                // Table, column (Modifier)
    3332         [ #  # ]:          0 :             if(pColumnItem)
    3333                 :            :             {
    3334                 :          0 :                 nDragOffset = pColumnItem->IsTable()? 0 :
    3335         [ #  # ]:          0 :                 GetDragPos() - pBorders[GetDragAryPos()].nPos;
    3336                 :          0 :                 EvalModifier();
    3337                 :            : 
    3338                 :            :             }
    3339                 :            :             else
    3340                 :          0 :                 nDragOffset = 0;
    3341                 :          0 :             break;
    3342                 :            :         case RULER_TYPE_INDENT: {                // Paragraph indents (Modifier)
    3343         [ #  # ]:          0 :             if( bContentProtected )
    3344                 :          0 :                 return sal_False;
    3345                 :          0 :             sal_uInt16 nIndent = INDENT_LEFT_MARGIN;
    3346         [ #  # ]:          0 :             if((nIndent) == GetDragAryPos() + INDENT_GAP) {  // Left paragraph indent
    3347                 :          0 :                 pIndents[0] = pIndents[INDENT_FIRST_LINE];
    3348                 :          0 :                 pIndents[0].nStyle |= RULER_STYLE_DONTKNOW;
    3349                 :          0 :                 EvalModifier();
    3350                 :            :             }
    3351                 :            :             else
    3352                 :          0 :                 nDragType = DRAG_OBJECT;
    3353                 :          0 :             pIndents[1] = pIndents[GetDragAryPos()+INDENT_GAP];
    3354                 :          0 :             pIndents[1].nStyle |= RULER_STYLE_DONTKNOW;
    3355                 :          0 :             break;
    3356                 :            :         }
    3357                 :            :         case RULER_TYPE_TAB:                // Tabs (Modifier)
    3358         [ #  # ]:          0 :             if( bContentProtected ) return sal_False;
    3359                 :          0 :             EvalModifier();
    3360                 :          0 :             pTabs[0] = pTabs[GetDragAryPos()+1];
    3361                 :          0 :             pTabs[0].nStyle |= RULER_STYLE_DONTKNOW;
    3362                 :          0 :             break;
    3363                 :            :         default:
    3364                 :          0 :             nDragType = NONE;
    3365                 :            :         }
    3366                 :            :     }
    3367                 :            :     else
    3368                 :          0 :         nDragType = NONE;
    3369         [ #  # ]:          0 :     if(bOk)
    3370                 :          0 :         CalcMinMax();
    3371                 :          0 :     return bOk;
    3372                 :            : }
    3373                 :            : 
    3374                 :            : 
    3375                 :          0 : void  SvxRuler::Drag()
    3376                 :            : 
    3377                 :            : /* [Description]
    3378                 :            : 
    3379                 :            :    SV-Draghandler
    3380                 :            : */
    3381                 :            : {
    3382         [ #  # ]:          0 :     if(IsDragCanceled())
    3383                 :            :     {
    3384                 :          0 :         Ruler::Drag();
    3385                 :          0 :         return;
    3386                 :            :     }
    3387   [ #  #  #  #  :          0 :     switch(GetDragType()) {
                   #  # ]
    3388                 :            :     case RULER_TYPE_MARGIN1:        // left edge of the surrounding Frame
    3389                 :          0 :         DragMargin1();
    3390                 :          0 :         pRuler_Imp->lLastLMargin=GetMargin1();
    3391                 :          0 :         break;
    3392                 :            :     case RULER_TYPE_MARGIN2:        // right edge of the surrounding Frame
    3393                 :          0 :         DragMargin2();
    3394                 :          0 :         pRuler_Imp->lLastRMargin = GetMargin2();
    3395                 :          0 :         break;
    3396                 :            :     case RULER_TYPE_INDENT:         // Paragraph indents
    3397                 :          0 :         DragIndents();
    3398                 :          0 :         break;
    3399                 :            :     case RULER_TYPE_BORDER:         // Table, columns
    3400         [ #  # ]:          0 :         if(pColumnItem)
    3401                 :          0 :             DragBorders();
    3402         [ #  # ]:          0 :         else if(pObjectItem)
    3403                 :          0 :             DragObjectBorder();
    3404                 :          0 :         break;
    3405                 :            :     case RULER_TYPE_TAB:            // Tabs
    3406                 :          0 :         DragTabs();
    3407                 :          0 :         break;
    3408                 :            :     default: ;//prevent warning
    3409                 :            :     }
    3410                 :          0 :     Ruler::Drag();
    3411                 :            : }
    3412                 :            : 
    3413                 :            : 
    3414                 :          0 : void SvxRuler::EndDrag()
    3415                 :            : 
    3416                 :            : /* [Description]
    3417                 :            : 
    3418                 :            :    SV-handler; is called when ending the dragging. Triggers the updating of data
    3419                 :            :    on the application, by calling the respective Apply...() methods to send the
    3420                 :            :    data to the application.
    3421                 :            : */
    3422                 :            : {
    3423                 :          0 :     const sal_Bool bUndo = IsDragCanceled();
    3424                 :          0 :     const long lPos = GetDragPos();
    3425                 :          0 :     DrawLine_Impl(lTabPos, 6, bHorz);
    3426                 :          0 :     lTabPos=-1;
    3427         [ #  # ]:          0 :     if(!bUndo)
    3428   [ #  #  #  #  :          0 :         switch(GetDragType())
                      # ]
    3429                 :            :         {
    3430                 :            :           case RULER_TYPE_MARGIN1:   // upper left edge of the surrounding Frame
    3431                 :            :           case RULER_TYPE_MARGIN2:   // lower right edge of the surrounding Frame
    3432                 :            :             {
    3433 [ #  # ][ #  # ]:          0 :                 if(!pColumnItem || !pColumnItem->IsTable())
                 [ #  # ]
    3434                 :          0 :                     ApplyMargins();
    3435                 :            : 
    3436   [ #  #  #  # ]:          0 :                 if(pColumnItem &&
         [ #  # ][ #  # ]
    3437                 :          0 :                    (pColumnItem->IsTable() ||
    3438                 :            :                     (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)))
    3439                 :          0 :                     ApplyBorders();
    3440                 :            : 
    3441                 :            :             }
    3442                 :          0 :             break;
    3443                 :            :           case RULER_TYPE_BORDER:                // Table, columns
    3444 [ #  # ][ #  # ]:          0 :             if(lInitialDragPos != lPos ||
                 [ #  # ]
    3445                 :            :                 (pRuler_Imp->bIsTableRows && bHorz)) //special case - the null offset is changed here
    3446                 :            :             {
    3447         [ #  # ]:          0 :                 if(pColumnItem)
    3448                 :            :                 {
    3449                 :          0 :                     ApplyBorders();
    3450         [ #  # ]:          0 :                     if(bHorz)
    3451                 :          0 :                         UpdateTabs();
    3452                 :            :                 }
    3453         [ #  # ]:          0 :                 else if(pObjectItem)
    3454                 :          0 :                     ApplyObject();
    3455                 :            :             }
    3456                 :          0 :             break;
    3457                 :            :           case RULER_TYPE_INDENT:                // Paragraph indents
    3458         [ #  # ]:          0 :             if(lInitialDragPos != lPos)
    3459                 :          0 :                 ApplyIndents();
    3460                 :          0 :             SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
    3461                 :          0 :             break;
    3462                 :            :           case RULER_TYPE_TAB:                // Tabs
    3463                 :            :             {
    3464                 :          0 :                 ApplyTabs();
    3465                 :          0 :                 pTabs[GetDragAryPos()].nStyle &= ~RULER_STYLE_INVISIBLE;
    3466                 :          0 :                 SetTabs(nTabCount, pTabs+TAB_GAP);
    3467                 :            :             }
    3468                 :          0 :             break;
    3469                 :            :             default: ; //prevent warning
    3470                 :            :         }
    3471                 :          0 :     nDragType = NONE;
    3472                 :          0 :     Ruler::EndDrag();
    3473         [ #  # ]:          0 :     if(bUndo)
    3474         [ #  # ]:          0 :         for(sal_uInt16 i=0;i<pRuler_Imp->nControlerItems;i++)
    3475                 :            :         {
    3476                 :          0 :             pCtrlItem[i]->ClearCache();
    3477                 :          0 :             pCtrlItem[i]->GetBindings().Invalidate(pCtrlItem[i]->GetId());
    3478                 :            :         }
    3479                 :          0 : }
    3480                 :            : 
    3481                 :            : 
    3482                 :          0 : void SvxRuler::ExtraDown()
    3483                 :            : 
    3484                 :            : /* [Description]
    3485                 :            : 
    3486                 :            :    Overloaded SV method, sets the new type for the Default tab.
    3487                 :            : */
    3488                 :            : 
    3489                 :            : {
    3490                 :            :     // Switch Tab Type
    3491 [ #  # ][ #  # ]:          0 :     if(pTabStopItem &&
    3492                 :            :         (nFlags & SVXRULER_SUPPORT_TABS) ==        SVXRULER_SUPPORT_TABS) {
    3493                 :          0 :         ++nDefTabType;
    3494         [ #  # ]:          0 :         if(RULER_TAB_DEFAULT == nDefTabType)
    3495                 :          0 :             nDefTabType = RULER_TAB_LEFT;
    3496                 :          0 :         SetExtraType(RULER_EXTRA_TAB, nDefTabType);
    3497                 :            :     }
    3498                 :          0 :     Ruler::ExtraDown();
    3499                 :          0 : }
    3500                 :            : 
    3501                 :            : 
    3502                 :       1032 : void SvxRuler::Notify(SfxBroadcaster&, const SfxHint& rHint)
    3503                 :            : 
    3504                 :            : /* [Description]
    3505                 :            : 
    3506                 :            :    Report through the bindings that the status update is completed. The ruler
    3507                 :            :    updates its appearance and gets registered again in the bindings.
    3508                 :            : */
    3509                 :            : 
    3510                 :            : {
    3511                 :            :     // start update
    3512   [ +  +  +  +  :       3080 :     if(bActive &&
           +  - ][ +  + ]
    3513                 :       1026 :         rHint.Type() == TYPE(SfxSimpleHint) &&
    3514                 :       1022 :      ((SfxSimpleHint&) rHint ).GetId() == SFX_HINT_UPDATEDONE ) {
    3515                 :       1022 :         Update();
    3516                 :       1022 :         EndListening(*pBindings);
    3517                 :       1022 :         bValid = sal_True;
    3518                 :       1022 :         bListening = sal_False;
    3519                 :            :     }
    3520                 :       1032 : }
    3521                 :            : 
    3522                 :            : 
    3523                 :          0 : IMPL_LINK_INLINE_START( SvxRuler, MenuSelect, Menu *, pMenu )
    3524                 :            : 
    3525                 :            : /* [Description]
    3526                 :            : 
    3527                 :            :    Handler of the context menus for switching the unit of measurement
    3528                 :            : */
    3529                 :            : 
    3530                 :            : {
    3531                 :          0 :     SetUnit(FieldUnit(pMenu->GetCurItemId()));
    3532                 :          0 :     return 0;
    3533                 :            : }
    3534                 :          0 : IMPL_LINK_INLINE_END( SvxRuler, MenuSelect, Menu *, pMenu )
    3535                 :            : 
    3536                 :            : 
    3537                 :          0 : IMPL_LINK( SvxRuler, TabMenuSelect, Menu *, pMenu )
    3538                 :            : 
    3539                 :            : /* [Description]
    3540                 :            : 
    3541                 :            :    Handler of the tab menu for setting the type
    3542                 :            : */
    3543                 :            : 
    3544                 :            : {
    3545 [ #  # ][ #  # ]:          0 :     if(pTabStopItem && pTabStopItem->Count() > pRuler_Imp->nIdx)
                 [ #  # ]
    3546                 :            :     {
    3547         [ #  # ]:          0 :         SvxTabStop aTabStop = (*pTabStopItem)[pRuler_Imp->nIdx];
    3548         [ #  # ]:          0 :         aTabStop.GetAdjustment() = ToAttrTab_Impl(pMenu->GetCurItemId()-1);
    3549         [ #  # ]:          0 :         pTabStopItem->Remove(pRuler_Imp->nIdx);
    3550         [ #  # ]:          0 :         pTabStopItem->Insert(aTabStop);
    3551         [ #  # ]:          0 :         sal_uInt16 nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
    3552         [ #  # ]:          0 :         pBindings->GetDispatcher()->Execute( nTabStopId, SFX_CALLMODE_RECORD, pTabStopItem, 0L );
    3553         [ #  # ]:          0 :         UpdateTabs();
    3554                 :          0 :         pRuler_Imp->nIdx = 0;
    3555                 :            :     }
    3556                 :          0 :     return 0;
    3557                 :            : }
    3558                 :            : 
    3559                 :            : 
    3560                 :          0 : void SvxRuler::Command( const CommandEvent& rCEvt )
    3561                 :            : 
    3562                 :            : /* [Description]
    3563                 :            : 
    3564                 :            :    Mouse context menu for switching the unit of measurement
    3565                 :            : */
    3566                 :            : 
    3567                 :            : {
    3568         [ #  # ]:          0 :     if ( COMMAND_CONTEXTMENU == rCEvt.GetCommand() )
    3569                 :            :     {
    3570                 :          0 :         CancelDrag();
    3571 [ #  # ][ #  # ]:          0 :         sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
    3572   [ #  #  #  # ]:          0 :         if ( pTabs &&
         [ #  # ][ #  # ]
    3573                 :            :              RULER_TYPE_TAB ==
    3574                 :          0 :              GetType( rCEvt.GetMousePosPixel(), &pRuler_Imp->nIdx ) &&
    3575                 :          0 :              pTabs[pRuler_Imp->nIdx+TAB_GAP].nStyle < RULER_TAB_DEFAULT )
    3576                 :            :         {
    3577         [ #  # ]:          0 :             PopupMenu aMenu;
    3578         [ #  # ]:          0 :             aMenu.SetSelectHdl(LINK(this, SvxRuler, TabMenuSelect));
    3579         [ #  # ]:          0 :             VirtualDevice aDev;
    3580                 :          0 :             const Size aSz(RULER_TAB_WIDTH+2, RULER_TAB_HEIGHT+2);
    3581         [ #  # ]:          0 :             aDev.SetOutputSize(aSz);
    3582 [ #  # ][ #  # ]:          0 :             aDev.SetBackground(Wallpaper(Color(COL_WHITE)));
                 [ #  # ]
    3583                 :          0 :             const Point aPt(aSz.Width() / 2, aSz.Height() / 2);
    3584                 :            : 
    3585         [ #  # ]:          0 :             for ( sal_uInt16 i = RULER_TAB_LEFT; i < RULER_TAB_DEFAULT; ++i )
    3586                 :            :             {
    3587         [ #  # ]:          0 :                 sal_uInt16 nStyle = bRTL ? i|RULER_TAB_RTL : i;
    3588         [ #  # ]:          0 :                 nStyle |= (sal_uInt16)(bHorz ? WB_HORZ : WB_VERT);
    3589         [ #  # ]:          0 :                 DrawTab(&aDev, aPt, nStyle);
    3590                 :            :                 aMenu.InsertItem(i+1,
    3591         [ #  # ]:          0 :                                  String(ResId(RID_SVXSTR_RULER_START+i, DIALOG_MGR())),
    3592 [ #  # ][ #  # ]:          0 :                                  Image(aDev.GetBitmap(Point(), aSz), Color(COL_WHITE)));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3593         [ #  # ]:          0 :                 aMenu.CheckItem(i+1, i == pTabs[pRuler_Imp->nIdx+TAB_GAP].nStyle);
    3594         [ #  # ]:          0 :                 aDev.SetOutputSize(aSz); // delete device
    3595                 :            :             }
    3596 [ #  # ][ #  # ]:          0 :             aMenu.Execute( this, rCEvt.GetMousePosPixel() );
                 [ #  # ]
    3597                 :            :         }
    3598                 :            :         else
    3599                 :            :         {
    3600 [ #  # ][ #  # ]:          0 :             PopupMenu aMenu(ResId(RID_SVXMN_RULER, DIALOG_MGR()));
    3601         [ #  # ]:          0 :             aMenu.SetSelectHdl(LINK(this, SvxRuler, MenuSelect));
    3602                 :          0 :             FieldUnit eUnit = GetUnit();
    3603         [ #  # ]:          0 :             const sal_uInt16 nCount = aMenu.GetItemCount();
    3604                 :            : 
    3605                 :          0 :             sal_Bool bReduceMetric = 0 != (nFlags &SVXRULER_SUPPORT_REDUCED_METRIC);
    3606         [ #  # ]:          0 :             for ( sal_uInt16 i = nCount; i; --i )
    3607                 :            :             {
    3608         [ #  # ]:          0 :                 const sal_uInt16 nId = aMenu.GetItemId(i - 1);
    3609         [ #  # ]:          0 :                 aMenu.CheckItem(nId, nId == (sal_uInt16)eUnit);
    3610 [ #  # ][ #  # ]:          0 :                 if(bReduceMetric &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3611                 :            :                         (nId == FUNIT_M ||
    3612                 :            :                          nId == FUNIT_KM ||
    3613                 :            :                          nId == FUNIT_FOOT ||
    3614                 :            :                          nId == FUNIT_MILE ||
    3615                 :            :                          nId == FUNIT_CHAR ||
    3616                 :            :                          nId == FUNIT_LINE ))
    3617                 :            :                 {
    3618 [ #  # ][ #  # ]:          0 :                     if (( nId == FUNIT_CHAR ) && bHorz )
    3619                 :            :                            ;
    3620 [ #  # ][ #  # ]:          0 :                     else if (( nId == FUNIT_LINE ) && !bHorz )
    3621                 :            :                            ;
    3622                 :            :                     else
    3623         [ #  # ]:          0 :                            aMenu.RemoveItem(i - 1);
    3624                 :            :                 }
    3625                 :            :             }
    3626 [ #  # ][ #  # ]:          0 :             aMenu.Execute( this, rCEvt.GetMousePosPixel() );
    3627                 :            :         }
    3628                 :            :     }
    3629                 :            :     else
    3630                 :          0 :         Ruler::Command( rCEvt );
    3631                 :          0 : }
    3632                 :            : 
    3633                 :            : 
    3634                 :         14 : sal_uInt16 SvxRuler::GetActRightColumn(
    3635                 :            :     sal_Bool bForceDontConsiderHidden, sal_uInt16 nAct ) const
    3636                 :            : {
    3637         [ +  - ]:         14 :     if( nAct == USHRT_MAX )
    3638                 :         14 :         nAct = pColumnItem->GetActColumn();
    3639                 :          0 :     else nAct++; //To be able to pass on the ActDrag
    3640                 :            : 
    3641                 :            :     sal_Bool bConsiderHidden = !bForceDontConsiderHidden &&
    3642 [ -  + ][ #  # ]:         14 :         !( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
    3643                 :            : 
    3644         [ +  - ]:         14 :     while( nAct < pColumnItem->Count() - 1 )
    3645                 :            :     {
    3646 [ -  + ][ #  # ]:         14 :         if( (*pColumnItem)[nAct].bVisible || bConsiderHidden )
                 [ +  - ]
    3647                 :         14 :             return nAct;
    3648                 :            :         else
    3649                 :          0 :             nAct++;
    3650                 :            :     }
    3651                 :         14 :     return USHRT_MAX;
    3652                 :            : }
    3653                 :            : 
    3654                 :            : 
    3655                 :            : 
    3656                 :          0 : sal_uInt16 SvxRuler::GetActLeftColumn(
    3657                 :            :     sal_Bool bForceDontConsiderHidden, sal_uInt16 nAct ) const
    3658                 :            : {
    3659         [ #  # ]:          0 :     if(nAct==USHRT_MAX)
    3660                 :          0 :         nAct=pColumnItem->GetActColumn();
    3661                 :            : 
    3662                 :          0 :     sal_uInt16 nLOffs=1;
    3663                 :            : 
    3664                 :            :     sal_Bool bConsiderHidden = !bForceDontConsiderHidden &&
    3665 [ #  # ][ #  # ]:          0 :         !( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
    3666                 :            : 
    3667         [ #  # ]:          0 :     while(nAct>=nLOffs)
    3668                 :            :     {
    3669 [ #  # ][ #  # ]:          0 :         if( (*pColumnItem)[ nAct - nLOffs ].bVisible || bConsiderHidden )
                 [ #  # ]
    3670                 :          0 :             return nAct-nLOffs;
    3671                 :            :         else
    3672                 :          0 :             nLOffs++;
    3673                 :            :     }
    3674                 :          0 :     return USHRT_MAX;
    3675                 :            : }
    3676                 :            : 
    3677                 :            : 
    3678                 :          7 : sal_Bool SvxRuler::IsActLastColumn(
    3679                 :            :     sal_Bool bForceDontConsiderHidden, sal_uInt16 nAct) const
    3680                 :            : {
    3681                 :          7 :     return GetActRightColumn(bForceDontConsiderHidden, nAct)==USHRT_MAX;
    3682                 :            : }
    3683                 :            : 
    3684                 :          0 : sal_Bool SvxRuler::IsActFirstColumn(
    3685                 :            :     sal_Bool bForceDontConsiderHidden, sal_uInt16 nAct) const
    3686                 :            : {
    3687                 :          0 :     return GetActLeftColumn(bForceDontConsiderHidden, nAct)==USHRT_MAX;
    3688                 :            : }
    3689                 :            : 
    3690                 :          0 : long SvxRuler::CalcPropMaxRight(sal_uInt16 nCol) const
    3691                 :            : {
    3692                 :            : 
    3693         [ #  # ]:          0 :     if(!(nDragType & DRAG_OBJECT_SIZE_LINEAR))
    3694                 :            :     {
    3695                 :            :         // Remove the minimum width for all affected columns
    3696                 :            :         // starting from the right edge
    3697                 :          0 :         long _nMaxRight = GetMargin2()-GetMargin1();
    3698                 :            : 
    3699                 :          0 :         long lFences=0;
    3700                 :          0 :         long lMinSpace=USHRT_MAX;
    3701                 :            :         long lOldPos;
    3702                 :          0 :         long lColumns=0;
    3703                 :            :         sal_uInt16 nStart;
    3704         [ #  # ]:          0 :         if(!pColumnItem->IsTable())
    3705                 :            :         {
    3706         [ #  # ]:          0 :             if(nCol==USHRT_MAX)
    3707                 :            :             {
    3708                 :          0 :                 lOldPos=GetMargin1();
    3709                 :          0 :                 nStart=0;
    3710                 :            :             }
    3711                 :            :             else
    3712                 :            :             {
    3713                 :          0 :                 lOldPos=pBorders[nCol].nPos+pBorders[nCol].nWidth;
    3714                 :          0 :                 nStart=nCol+1;
    3715                 :          0 :                 lFences=pBorders[nCol].nWidth;
    3716                 :            :             }
    3717                 :            : 
    3718         [ #  # ]:          0 :             for(sal_uInt16 i = nStart; i < nBorderCount-1; ++i)
    3719                 :            :             {
    3720                 :          0 :                 long lWidth=pBorders[i].nPos-lOldPos;
    3721                 :          0 :                 lColumns+=lWidth;
    3722         [ #  # ]:          0 :                 if(lWidth<lMinSpace)
    3723                 :          0 :                     lMinSpace=lWidth;
    3724                 :          0 :                 lOldPos=pBorders[i].nPos+pBorders[i].nWidth;
    3725                 :          0 :                 lFences+=pBorders[i].nWidth;
    3726                 :            :             }
    3727                 :          0 :             long lWidth=GetMargin2()-lOldPos;
    3728                 :          0 :             lColumns+=lWidth;
    3729         [ #  # ]:          0 :             if(lWidth<lMinSpace)
    3730                 :          0 :                 lMinSpace=lWidth;
    3731                 :            :         }
    3732                 :            :         else
    3733                 :            :         {
    3734                 :            :             sal_uInt16 nActCol;
    3735         [ #  # ]:          0 :             if(nCol==USHRT_MAX) //CalcMinMax for LeftMargin
    3736                 :            :             {
    3737                 :          0 :                 lOldPos=GetMargin1();
    3738                 :            :             }
    3739                 :            :             else
    3740                 :            :             {
    3741                 :          0 :                 lOldPos=pBorders[nCol].nPos;
    3742                 :            :             }
    3743                 :          0 :             lColumns=GetMargin2()-lOldPos;
    3744                 :          0 :             nActCol=nCol;
    3745                 :          0 :             lFences=0;
    3746 [ #  # ][ #  # ]:          0 :             while(nActCol<nBorderCount||nActCol==USHRT_MAX)
                 [ #  # ]
    3747                 :            :             {
    3748                 :            :                 sal_uInt16 nRight;
    3749         [ #  # ]:          0 :                 if(nActCol==USHRT_MAX)
    3750                 :            :                 {
    3751                 :          0 :                     nRight=0;
    3752         [ #  # ]:          0 :                     while(!(*pColumnItem)[nRight].bVisible)
    3753                 :          0 :                         nRight++;
    3754                 :            :                 }
    3755                 :            :                 else
    3756                 :          0 :                     nRight=GetActRightColumn(sal_False, nActCol);
    3757                 :            :                 long lWidth;
    3758         [ #  # ]:          0 :                 if(nRight!=USHRT_MAX)
    3759                 :            :                 {
    3760                 :          0 :                     lWidth=pBorders[nRight].nPos-lOldPos;
    3761                 :          0 :                     lOldPos=pBorders[nRight].nPos;
    3762                 :            :                 }
    3763                 :            :                 else
    3764                 :          0 :                     lWidth=GetMargin2()-lOldPos;
    3765                 :          0 :                 nActCol=nRight;
    3766         [ #  # ]:          0 :                 if(lWidth<lMinSpace)
    3767                 :          0 :                     lMinSpace=lWidth;
    3768         [ #  # ]:          0 :                 if(nActCol==USHRT_MAX)
    3769                 :          0 :                     break;
    3770                 :            :             }
    3771                 :            :         }
    3772                 :            : 
    3773                 :          0 :         _nMaxRight-=(long)(lFences+lMinFrame/(float)lMinSpace*lColumns);
    3774                 :          0 :         return _nMaxRight;
    3775                 :            :     }
    3776                 :            :     else
    3777                 :            :     {
    3778         [ #  # ]:          0 :         if(pColumnItem->IsTable())
    3779                 :            :         {
    3780                 :          0 :             sal_uInt16 nVisCols=0;
    3781         [ #  # ]:          0 :             for(sal_uInt16 i=GetActRightColumn(sal_False, nCol);i<nBorderCount;)
    3782                 :            :             {
    3783         [ #  # ]:          0 :                 if((*pColumnItem)[i].bVisible)
    3784                 :          0 :                     nVisCols++;
    3785                 :          0 :                 i=GetActRightColumn(sal_False, i);
    3786                 :            :             }
    3787                 :          0 :             return GetMargin2()-GetMargin1()-(nVisCols+1)*lMinFrame;
    3788                 :            :         }
    3789                 :            :         else
    3790                 :            :         {
    3791                 :          0 :             long lWidth=0;
    3792         [ #  # ]:          0 :             for(sal_uInt16 i=nCol;i<nBorderCount-1;i++)
    3793                 :            :             {
    3794                 :          0 :                 lWidth+=lMinFrame+pBorders[i].nWidth;
    3795                 :            :             }
    3796                 :          0 :             return GetMargin2()-GetMargin1()-lWidth;
    3797                 :            :         }
    3798                 :            :     }
    3799                 :            : }
    3800                 :            : 
    3801                 :            : // Tab stops relative to indent (#i24363#)
    3802                 :       1384 : void SvxRuler::SetTabsRelativeToIndent( sal_Bool bRel )
    3803                 :            : {
    3804                 :       1384 :     pRuler_Imp->bIsTabsRelativeToIndent = bRel;
    3805                 :       1384 : }
    3806                 :            : 
    3807                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10