LCOV - code coverage report
Current view: top level - libreoffice/cui/source/tabpages - swpossizetabpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 809 0.1 %
Date: 2012-12-17 Functions: 2 38 5.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <cstddef>
      21             : #include <swpossizetabpage.hxx>
      22             : #include <dialmgr.hxx>
      23             : #include <svx/dlgutil.hxx>
      24             : #include <svx/anchorid.hxx>
      25             : #include <svl/aeitem.hxx>
      26             : #include <svx/swframevalidation.hxx>
      27             : #include <cuires.hrc>
      28             : #include <swpossizetabpage.hrc>
      29             : #include <svx/htmlmode.hxx>
      30             : #include <svx/svdview.hxx>
      31             : #include <svx/svdpagv.hxx>
      32             : #include <svx/rectenum.hxx>
      33             : #include <sal/macros.h>
      34             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      35             : #include <com/sun/star/text/HoriOrientation.hpp>
      36             : #include <com/sun/star/text/VertOrientation.hpp>
      37             : #include <com/sun/star/text/RelOrientation.hpp>
      38             : #include <svx/dialogs.hrc>
      39             : 
      40             : using namespace ::com::sun::star::text;
      41             : #define SwFPos SvxSwFramePosString
      42             : 
      43             : struct FrmMap
      44             : {
      45             :     SvxSwFramePosString::StringId   eStrId;
      46             :     SvxSwFramePosString::StringId   eMirrorStrId;
      47             :     short                           nAlign;
      48             :     sal_uLong                           nLBRelations;
      49             : };
      50             : 
      51             : struct RelationMap
      52             : {
      53             :     SvxSwFramePosString::StringId   eStrId;
      54             :     SvxSwFramePosString::StringId   eMirrorStrId;
      55             :     sal_uLong  nLBRelation;
      56             :     short nRelation;
      57             : };
      58             : struct StringIdPair_Impl
      59             : {
      60             :     SvxSwFramePosString::StringId eHori;
      61             :     SvxSwFramePosString::StringId eVert;
      62             : };
      63             : 
      64             : #define LB_FRAME                0x00000001L // paragraph text area
      65             : #define LB_PRTAREA              0x00000002L // paragraph text area + indents
      66             : #define LB_VERT_FRAME           0x00000004L // vertical paragraph text area
      67             : #define LB_VERT_PRTAREA         0x00000008L // vertical paragraph text area + indents
      68             : #define LB_REL_FRM_LEFT         0x00000010L // left paragraph margin
      69             : #define LB_REL_FRM_RIGHT        0x00000020L // right paragraph margin
      70             : 
      71             : #define LB_REL_PG_LEFT          0x00000040L // left page margin
      72             : #define LB_REL_PG_RIGHT         0x00000080L // right page margin
      73             : #define LB_REL_PG_FRAME         0x00000100L // complete page
      74             : #define LB_REL_PG_PRTAREA       0x00000200L // text area of page
      75             : 
      76             : #define LB_FLY_REL_PG_LEFT      0x00000400L // left frame margin
      77             : #define LB_FLY_REL_PG_RIGHT     0x00000800L // right frame margin
      78             : #define LB_FLY_REL_PG_FRAME     0x00001000L // complete frame
      79             : #define LB_FLY_REL_PG_PRTAREA   0x00002000L // frame interior
      80             : 
      81             : #define LB_REL_BASE             0x00010000L // as char, relative to baseline
      82             : #define LB_REL_CHAR             0x00020000L // as char, relative to character
      83             : #define LB_REL_ROW              0x00040000L // as char, relative to line
      84             : 
      85             : // #i22305#
      86             : #define LB_FLY_VERT_FRAME       0x00100000L // vertical entire frame
      87             : #define LB_FLY_VERT_PRTAREA     0x00200000L // vertical frame text area
      88             : 
      89             : // #i22341#
      90             : #define LB_VERT_LINE            0x00400000L // vertical text line
      91             : 
      92             : static RelationMap aRelationMap[] =
      93             : {
      94             :     {SwFPos::FRAME,         SwFPos::FRAME,             LB_FRAME,           RelOrientation::FRAME},
      95             :     {SwFPos::PRTAREA,       SwFPos::PRTAREA,           LB_PRTAREA,         RelOrientation::PRINT_AREA},
      96             :     {SwFPos::REL_PG_LEFT,   SwFPos::MIR_REL_PG_LEFT,   LB_REL_PG_LEFT,     RelOrientation::PAGE_LEFT},
      97             :     {SwFPos::REL_PG_RIGHT,  SwFPos::MIR_REL_PG_RIGHT,  LB_REL_PG_RIGHT,    RelOrientation::PAGE_RIGHT},
      98             :     {SwFPos::REL_FRM_LEFT,  SwFPos::MIR_REL_FRM_LEFT,  LB_REL_FRM_LEFT,    RelOrientation::FRAME_LEFT},
      99             :     {SwFPos::REL_FRM_RIGHT, SwFPos::MIR_REL_FRM_RIGHT, LB_REL_FRM_RIGHT,   RelOrientation::FRAME_RIGHT},
     100             :     {SwFPos::REL_PG_FRAME,  SwFPos::REL_PG_FRAME,      LB_REL_PG_FRAME,    RelOrientation::PAGE_FRAME},
     101             :     {SwFPos::REL_PG_PRTAREA,SwFPos::REL_PG_PRTAREA,    LB_REL_PG_PRTAREA,  RelOrientation::PAGE_PRINT_AREA},
     102             :     {SwFPos::REL_CHAR,      SwFPos::REL_CHAR,          LB_REL_CHAR,        RelOrientation::CHAR},
     103             : 
     104             :     {SwFPos::FLY_REL_PG_LEFT,       SwFPos::FLY_MIR_REL_PG_LEFT,    LB_FLY_REL_PG_LEFT,     RelOrientation::PAGE_LEFT},
     105             :     {SwFPos::FLY_REL_PG_RIGHT,      SwFPos::FLY_MIR_REL_PG_RIGHT,   LB_FLY_REL_PG_RIGHT,    RelOrientation::PAGE_RIGHT},
     106             :     {SwFPos::FLY_REL_PG_FRAME,      SwFPos::FLY_REL_PG_FRAME,       LB_FLY_REL_PG_FRAME,    RelOrientation::PAGE_FRAME},
     107             :     {SwFPos::FLY_REL_PG_PRTAREA,    SwFPos::FLY_REL_PG_PRTAREA,     LB_FLY_REL_PG_PRTAREA,  RelOrientation::PAGE_PRINT_AREA},
     108             : 
     109             :     {SwFPos::REL_BORDER,        SwFPos::REL_BORDER,             LB_VERT_FRAME,          RelOrientation::FRAME},
     110             :     {SwFPos::REL_PRTAREA,       SwFPos::REL_PRTAREA,            LB_VERT_PRTAREA,        RelOrientation::PRINT_AREA},
     111             : 
     112             :     // #i22305#
     113             :     {SwFPos::FLY_REL_PG_FRAME,      SwFPos::FLY_REL_PG_FRAME,       LB_FLY_VERT_FRAME,      RelOrientation::FRAME},
     114             :     {SwFPos::FLY_REL_PG_PRTAREA,    SwFPos::FLY_REL_PG_PRTAREA,     LB_FLY_VERT_PRTAREA,    RelOrientation::PRINT_AREA},
     115             : 
     116             :     // #i22341#
     117             :     {SwFPos::REL_LINE,  SwFPos::REL_LINE,   LB_VERT_LINE,   RelOrientation::TEXT_LINE}
     118             : };
     119             : 
     120             : static RelationMap aAsCharRelationMap[] =
     121             : {
     122             :     {SwFPos::REL_BASE,  SwFPos::REL_BASE,   LB_REL_BASE,   RelOrientation::FRAME},
     123             :     {SwFPos::REL_CHAR,  SwFPos::REL_CHAR,   LB_REL_CHAR,   RelOrientation::FRAME},
     124             :     {SwFPos::REL_ROW,   SwFPos::REL_ROW,   LB_REL_ROW,     RelOrientation::FRAME}
     125             : };
     126             : 
     127             : /*--------------------------------------------------------------------
     128             :     Anchored at page
     129             :  --------------------------------------------------------------------*/
     130             : 
     131             : #define HORI_PAGE_REL   (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_PG_LEFT| \
     132             :                         LB_REL_PG_RIGHT)
     133             : 
     134             : static FrmMap aHPageMap[] =
     135             : {
     136             :     {SwFPos::LEFT,       SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      HORI_PAGE_REL},
     137             :     {SwFPos::RIGHT,      SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HORI_PAGE_REL},
     138             :     {SwFPos::CENTER_HORI,SwFPos::CENTER_HORI,    HoriOrientation::CENTER,    HORI_PAGE_REL},
     139             :     {SwFPos::FROMLEFT,   SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      HORI_PAGE_REL}
     140             : };
     141             : 
     142             : static FrmMap aHPageHtmlMap[] =
     143             : {
     144             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      LB_REL_PG_FRAME}
     145             : };
     146             : 
     147             : #define VERT_PAGE_REL   (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     148             : 
     149             : static FrmMap aVPageMap[] =
     150             : {
     151             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       VERT_PAGE_REL},
     152             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,    VERT_PAGE_REL},
     153             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,    VERT_PAGE_REL},
     154             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      VERT_PAGE_REL}
     155             : };
     156             : 
     157             : static FrmMap aVPageHtmlMap[] =
     158             : {
     159             :     {SwFPos::FROMTOP, SwFPos::FROMTOP,        VertOrientation::NONE,      LB_REL_PG_FRAME}
     160             : };
     161             : 
     162             : /*--------------------------------------------------------------------
     163             :     Anchored at frame
     164             :  --------------------------------------------------------------------*/
     165             : 
     166             : #define HORI_FRAME_REL  (LB_FLY_REL_PG_FRAME|LB_FLY_REL_PG_PRTAREA| \
     167             :                         LB_FLY_REL_PG_LEFT|LB_FLY_REL_PG_RIGHT)
     168             : 
     169             : static FrmMap aHFrameMap[] =
     170             : {
     171             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,  HORI_FRAME_REL},
     172             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HORI_FRAME_REL},
     173             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    HoriOrientation::CENTER,    HORI_FRAME_REL},
     174             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      HORI_FRAME_REL}
     175             : };
     176             : 
     177             : static FrmMap aHFlyHtmlMap[] =
     178             : {
     179             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      LB_FLY_REL_PG_FRAME},
     180             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      LB_FLY_REL_PG_FRAME}
     181             : };
     182             : 
     183             : // #i18732# - own vertical alignment map for to frame anchored objects
     184             : // #i22305#
     185             : #define VERT_FRAME_REL   (LB_VERT_FRAME|LB_FLY_VERT_PRTAREA)
     186             : 
     187             : static FrmMap aVFrameMap[] =
     188             : {
     189             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       VERT_FRAME_REL},
     190             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,    VERT_FRAME_REL},
     191             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,    VERT_FRAME_REL},
     192             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      VERT_FRAME_REL}
     193             : };
     194             : 
     195             : static FrmMap aVFlyHtmlMap[] =
     196             : {
     197             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       LB_FLY_VERT_FRAME},
     198             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      LB_FLY_VERT_FRAME}
     199             : };
     200             : 
     201             : static FrmMap aVMultiSelectionMap[] =
     202             : {
     203             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      0}
     204             : };
     205             : static FrmMap aHMultiSelectionMap[] =
     206             : {
     207             :     {SwFPos::FROMLEFT,      SwFPos::FROMLEFT,       HoriOrientation::NONE,      0}
     208             : };
     209             : 
     210             : /*--------------------------------------------------------------------
     211             :     Anchored at paragraph
     212             :  --------------------------------------------------------------------*/
     213             : 
     214             : #define HORI_PARA_REL   (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
     215             :                         LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
     216             :                         LB_REL_FRM_RIGHT)
     217             : 
     218             : static FrmMap aHParaMap[] =
     219             : {
     220             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      HORI_PARA_REL},
     221             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HORI_PARA_REL},
     222             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    HoriOrientation::CENTER,    HORI_PARA_REL},
     223             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      HORI_PARA_REL}
     224             : };
     225             : 
     226             : #define HTML_HORI_PARA_REL  (LB_FRAME|LB_PRTAREA)
     227             : 
     228             : static FrmMap aHParaHtmlMap[] =
     229             : {
     230             :     {SwFPos::LEFT,  SwFPos::LEFT,   HoriOrientation::LEFT,      HTML_HORI_PARA_REL},
     231             :     {SwFPos::RIGHT, SwFPos::RIGHT,  HoriOrientation::RIGHT,     HTML_HORI_PARA_REL}
     232             : };
     233             : 
     234             : static FrmMap aHParaHtmlAbsMap[] =
     235             : {
     236             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      HTML_HORI_PARA_REL},
     237             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HTML_HORI_PARA_REL}
     238             : };
     239             : 
     240             : 
     241             : #define VERT_PARA_REL   (LB_VERT_FRAME|LB_VERT_PRTAREA| \
     242             :                          LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     243             : 
     244             : static FrmMap aVParaMap[] =
     245             : {
     246             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       VERT_PARA_REL},
     247             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,    VERT_PARA_REL},
     248             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,    VERT_PARA_REL},
     249             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      VERT_PARA_REL}
     250             : };
     251             : 
     252             : static FrmMap aVParaHtmlMap[] =
     253             : {
     254             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       LB_VERT_PRTAREA}
     255             : };
     256             : 
     257             : /*--------------------------------------------------------------------
     258             :     Anchored at character
     259             :  --------------------------------------------------------------------*/
     260             : 
     261             : #define HORI_CHAR_REL   (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
     262             :                         LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
     263             :                         LB_REL_FRM_RIGHT|LB_REL_CHAR)
     264             : 
     265             : static FrmMap aHCharMap[] =
     266             : {
     267             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      HORI_CHAR_REL},
     268             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HORI_CHAR_REL},
     269             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    HoriOrientation::CENTER,    HORI_CHAR_REL},
     270             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      HORI_CHAR_REL}
     271             : };
     272             : 
     273             : #define HTML_HORI_CHAR_REL  (LB_FRAME|LB_PRTAREA|LB_REL_CHAR)
     274             : 
     275             : static FrmMap aHCharHtmlMap[] =
     276             : {
     277             :     {SwFPos::LEFT,          SwFPos::LEFT,           HoriOrientation::LEFT,      HTML_HORI_CHAR_REL},
     278             :     {SwFPos::RIGHT,         SwFPos::RIGHT,          HoriOrientation::RIGHT,     HTML_HORI_CHAR_REL}
     279             : };
     280             : 
     281             : static FrmMap aHCharHtmlAbsMap[] =
     282             : {
     283             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,          LB_PRTAREA|LB_REL_CHAR},
     284             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     LB_PRTAREA},
     285             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      LB_REL_PG_FRAME}
     286             : };
     287             : 
     288             : // #i18732# - allow vertical alignment at page areas
     289             : // #i22341# - handle <LB_REL_CHAR> on its own
     290             : #define VERT_CHAR_REL   (LB_VERT_FRAME|LB_VERT_PRTAREA| \
     291             :                          LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     292             : 
     293             : static FrmMap aVCharMap[] =
     294             : {
     295             :     // #i22341#
     296             :     // introduce mappings for new vertical alignment at top of line <LB_VERT_LINE>
     297             :     // and correct mapping for vertical alignment at character for position <FROM_BOTTOM>
     298             :     // Note: Because of these adjustments the map becomes ambigous in its values
     299             :     //       <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered
     300             :     //       in the methods <SwFrmPage::FillRelLB(..)>, <SwFrmPage::GetAlignment(..)>
     301             :     //       and <SwFrmPage::FillPosLB(..)>
     302             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,           VERT_CHAR_REL|LB_REL_CHAR},
     303             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,        VERT_CHAR_REL|LB_REL_CHAR},
     304             :     {SwFPos::BELOW,         SwFPos::BELOW,          VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR},
     305             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,        VERT_CHAR_REL|LB_REL_CHAR},
     306             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,          VERT_CHAR_REL},
     307             :     {SwFPos::FROMBOTTOM,    SwFPos::FROMBOTTOM,     VertOrientation::NONE,          LB_REL_CHAR|LB_VERT_LINE},
     308             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::LINE_TOP,      LB_VERT_LINE},
     309             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::LINE_BOTTOM,   LB_VERT_LINE},
     310             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::LINE_CENTER,   LB_VERT_LINE}
     311             : };
     312             : 
     313             : 
     314             : static FrmMap aVCharHtmlMap[] =
     315             : {
     316             :     {SwFPos::BELOW,         SwFPos::BELOW,          VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR}
     317             : };
     318             : 
     319             : static FrmMap aVCharHtmlAbsMap[] =
     320             : {
     321             :     {SwFPos::TOP,    SwFPos::TOP,            VertOrientation::TOP,           LB_REL_CHAR},
     322             :     {SwFPos::BELOW,  SwFPos::BELOW,          VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR}
     323             : };
     324             : /*--------------------------------------------------------------------
     325             :     anchored as character
     326             :  --------------------------------------------------------------------*/
     327             : 
     328             : static FrmMap aVAsCharMap[] =
     329             : {
     330             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,           LB_REL_BASE},
     331             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,        LB_REL_BASE},
     332             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,        LB_REL_BASE},
     333             : 
     334             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::CHAR_TOP,      LB_REL_CHAR},
     335             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR},
     336             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CHAR_CENTER,   LB_REL_CHAR},
     337             : 
     338             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::LINE_TOP,      LB_REL_ROW},
     339             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::LINE_BOTTOM,   LB_REL_ROW},
     340             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::LINE_CENTER,   LB_REL_ROW},
     341             : 
     342             :     {SwFPos::FROMBOTTOM,    SwFPos::FROMBOTTOM,     VertOrientation::NONE,          LB_REL_BASE}
     343             : };
     344             : 
     345             : static FrmMap aVAsCharHtmlMap[] =
     346             : {
     347             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,           LB_REL_BASE},
     348             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,        LB_REL_BASE},
     349             : 
     350             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::CHAR_TOP,      LB_REL_CHAR},
     351             : 
     352             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::LINE_TOP,      LB_REL_ROW},
     353             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::LINE_BOTTOM,   LB_REL_ROW},
     354             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::LINE_CENTER,   LB_REL_ROW}
     355             : };
     356             : 
     357           0 : static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap)
     358             : {
     359           0 :     if( pMap )
     360             :     {
     361           0 :         if( pMap == aVParaHtmlMap )
     362           0 :             return SAL_N_ELEMENTS(aVParaHtmlMap);
     363           0 :         if( pMap == aVAsCharHtmlMap )
     364           0 :             return SAL_N_ELEMENTS( aVAsCharHtmlMap );
     365           0 :         if( pMap == aHParaHtmlMap )
     366           0 :             return SAL_N_ELEMENTS( aHParaHtmlMap );
     367           0 :         if( pMap == aHParaHtmlAbsMap )
     368           0 :             return SAL_N_ELEMENTS( aHParaHtmlAbsMap );
     369           0 :         if( pMap == aVPageMap )
     370           0 :             return SAL_N_ELEMENTS( aVPageMap );
     371           0 :         if( pMap == aVPageHtmlMap )
     372           0 :             return SAL_N_ELEMENTS( aVPageHtmlMap );
     373           0 :         if( pMap == aVAsCharMap )
     374           0 :             return SAL_N_ELEMENTS( aVAsCharMap );
     375           0 :         if( pMap == aVParaMap )
     376           0 :             return SAL_N_ELEMENTS( aVParaMap );
     377           0 :         if( pMap == aHParaMap )
     378           0 :             return SAL_N_ELEMENTS( aHParaMap );
     379           0 :         if( pMap == aHFrameMap )
     380           0 :             return SAL_N_ELEMENTS( aHFrameMap );
     381           0 :         if( pMap == aVFrameMap )
     382           0 :             return SAL_N_ELEMENTS( aVFrameMap );
     383           0 :         if( pMap == aHCharMap )
     384           0 :             return SAL_N_ELEMENTS( aHCharMap );
     385           0 :         if( pMap == aHCharHtmlMap )
     386           0 :             return SAL_N_ELEMENTS( aHCharHtmlMap );
     387           0 :         if( pMap == aHCharHtmlAbsMap )
     388           0 :             return SAL_N_ELEMENTS( aHCharHtmlAbsMap );
     389           0 :         if( pMap == aVCharMap )
     390           0 :             return SAL_N_ELEMENTS( aVCharMap );
     391           0 :         if( pMap == aVCharHtmlMap )
     392           0 :             return SAL_N_ELEMENTS( aVCharHtmlMap );
     393           0 :         if( pMap == aVCharHtmlAbsMap )
     394           0 :             return SAL_N_ELEMENTS( aVCharHtmlAbsMap );
     395           0 :         if( pMap == aHPageHtmlMap )
     396           0 :             return SAL_N_ELEMENTS( aHPageHtmlMap );
     397           0 :         if( pMap == aHFlyHtmlMap )
     398           0 :             return SAL_N_ELEMENTS( aHFlyHtmlMap );
     399           0 :         if( pMap == aVFlyHtmlMap )
     400           0 :             return SAL_N_ELEMENTS( aVFlyHtmlMap );
     401           0 :         if( pMap == aVMultiSelectionMap )
     402           0 :             return SAL_N_ELEMENTS( aVMultiSelectionMap );
     403           0 :         if( pMap == aHMultiSelectionMap )
     404           0 :             return SAL_N_ELEMENTS( aHMultiSelectionMap );
     405           0 :         return SAL_N_ELEMENTS(aHPageMap);
     406             :     }
     407           0 :     return 0;
     408             : }
     409             : 
     410           0 : static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(
     411             :             SvxSwFramePosString::StringId eStringId, sal_Bool bVertical, sal_Bool bRTL)
     412             : {
     413             :     //special handling of STR_FROMLEFT
     414           0 :     if(SwFPos::FROMLEFT == eStringId)
     415             :     {
     416             :         eStringId = bVertical ?
     417             :             bRTL ? SwFPos::FROMBOTTOM : SwFPos::FROMTOP :
     418           0 :             bRTL ? SwFPos::FROMRIGHT : SwFPos::FROMLEFT;
     419           0 :         return eStringId;
     420             :     }
     421           0 :     if(bVertical)
     422             :     {
     423             :         //exchange horizontal strings with vertical strings and vice versa
     424             :         static const StringIdPair_Impl aHoriIds[] =
     425             :         {
     426             :             {SwFPos::LEFT,           SwFPos::TOP},
     427             :             {SwFPos::RIGHT,          SwFPos::BOTTOM},
     428             :             {SwFPos::CENTER_HORI,    SwFPos::CENTER_VERT},
     429             :             {SwFPos::FROMTOP,        SwFPos::FROMRIGHT},
     430             :             {SwFPos::REL_PG_LEFT,    SwFPos::REL_PG_TOP},
     431             :             {SwFPos::REL_PG_RIGHT,   SwFPos::REL_PG_BOTTOM} ,
     432             :             {SwFPos::REL_FRM_LEFT,   SwFPos::REL_FRM_TOP},
     433             :             {SwFPos::REL_FRM_RIGHT,  SwFPos::REL_FRM_BOTTOM}
     434             :         };
     435             :         static const StringIdPair_Impl aVertIds[] =
     436             :         {
     437             :             {SwFPos::TOP,            SwFPos::RIGHT},
     438             :             {SwFPos::BOTTOM,         SwFPos::LEFT },
     439             :             {SwFPos::CENTER_VERT,    SwFPos::CENTER_HORI},
     440             :             {SwFPos::FROMTOP,        SwFPos::FROMRIGHT },
     441             :             {SwFPos::REL_PG_TOP,     SwFPos::REL_PG_LEFT },
     442             :             {SwFPos::REL_PG_BOTTOM,  SwFPos::REL_PG_RIGHT } ,
     443             :             {SwFPos::REL_FRM_TOP,    SwFPos::REL_FRM_LEFT },
     444             :             {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
     445             :         };
     446             :         sal_uInt16 nIndex;
     447           0 :         for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex)
     448             :         {
     449           0 :             if(aHoriIds[nIndex].eHori == eStringId)
     450             :             {
     451           0 :                 eStringId = aHoriIds[nIndex].eVert;
     452           0 :                 return eStringId;
     453             :             }
     454             :         }
     455           0 :         nIndex = 0;
     456           0 :         for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
     457             :         {
     458           0 :             if(aVertIds[nIndex].eHori == eStringId)
     459             :             {
     460           0 :                 eStringId = aVertIds[nIndex].eVert;
     461           0 :                 break;
     462             :             }
     463             :         }
     464             :     }
     465           0 :     return eStringId;
     466             : }
     467             : // #i22341# - helper method in order to determine all possible
     468             : // listbox relations in a relation map for a given relation
     469           0 : static sal_uLong lcl_GetLBRelationsForRelations( const sal_uInt16 _nRel )
     470             : {
     471           0 :     sal_uLong nLBRelations = 0L;
     472             : 
     473           0 :     for ( sal_uInt16 nRelMapPos = 0; nRelMapPos < SAL_N_ELEMENTS(aRelationMap); ++nRelMapPos )
     474             :     {
     475           0 :         if ( aRelationMap[nRelMapPos].nRelation == _nRel )
     476             :         {
     477           0 :             nLBRelations |= aRelationMap[nRelMapPos].nLBRelation;
     478             :         }
     479             :     }
     480             : 
     481           0 :     return nLBRelations;
     482             : }
     483             : 
     484             : // #i22341# - helper method on order to determine all possible
     485             : // listbox relations in a relation map for a given string ID
     486           0 : static sal_uLong lcl_GetLBRelationsForStrID( const FrmMap* _pMap,
     487             :                                   const SvxSwFramePosString::StringId _eStrId,
     488             :                                   const bool _bUseMirrorStr )
     489             : {
     490           0 :     sal_uLong nLBRelations = 0L;
     491             : 
     492           0 :     std::size_t nRelMapSize = lcl_GetFrmMapCount( _pMap );
     493           0 :     for ( std::size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
     494             :     {
     495           0 :         if ( ( !_bUseMirrorStr && _pMap[nRelMapPos].eStrId == _eStrId ) ||
     496           0 :              ( _bUseMirrorStr && _pMap[nRelMapPos].eMirrorStrId == _eStrId ) )
     497             :         {
     498           0 :             nLBRelations |= _pMap[nRelMapPos].nLBRelations;
     499             :         }
     500             :     }
     501             : 
     502           0 :     return nLBRelations;
     503             : }
     504             : 
     505           0 : SvxSwPosSizeTabPage::SvxSwPosSizeTabPage( Window* pParent, const SfxItemSet& rInAttrs  ) :
     506           0 :     SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_SWPOSSIZE ), rInAttrs ),
     507             : #ifdef _MSC_VER
     508             : #pragma warning (disable : 4355)
     509             : #endif
     510           0 :     m_aSizeFL(    this, CUI_RES( FL_SIZE   ) ),
     511           0 :     m_aWidthFT(   this, CUI_RES( FT_WIDTH  ) ),
     512           0 :     m_aWidthMF(   this, CUI_RES( MF_WIDTH  ) ),
     513           0 :     m_aHeightFT(  this, CUI_RES( FT_HEIGHT ) ),
     514           0 :     m_aHeightMF(  this, CUI_RES( MF_HEIGHT ) ),
     515           0 :     m_aKeepRatioCB(this,CUI_RES( CB_KEEPRATIO) ),
     516           0 :     m_aSeparatorFL(this,CUI_RES( FL_SEPARATOR) ),
     517             : 
     518           0 :     m_aAnchorFL(  this, CUI_RES( FL_ANCHOR ) ),
     519           0 :     m_aToPageRB(  this, CUI_RES( RB_TOPAGE ) ),
     520           0 :     m_aToParaRB(  this, CUI_RES( RB_TOPARA ) ),
     521           0 :     m_aToCharRB(  this, CUI_RES( RB_TOCHAR ) ),
     522           0 :     m_aAsCharRB(  this, CUI_RES( RB_ASCHAR ) ),
     523           0 :     m_aToFrameRB( this, CUI_RES( RB_TOFRAME) ),
     524             : 
     525           0 :     m_aProtectionFL(  this, CUI_RES( FL_PROTECTION  ) ),
     526           0 :     m_aPositionCB(    this, CUI_RES( CB_POSITION    ) ),
     527           0 :     m_aSizeCB(        this, CUI_RES( CB_SIZE        ) ),
     528             : 
     529           0 :     m_aPositionFL(    this, CUI_RES( FL_POSITION    ) ),
     530           0 :     m_aHoriFT(        this, CUI_RES( FT_HORI        ) ),
     531           0 :     m_aHoriLB(        this, CUI_RES( LB_HORI        ) ),
     532           0 :     m_aHoriByFT(      this, CUI_RES( FT_HORIBY      ) ),
     533           0 :     m_aHoriByMF(      this, CUI_RES( MF_HORIBY      ) ),
     534           0 :     m_aHoriToFT(      this, CUI_RES( FT_HORITO      ) ),
     535           0 :     m_aHoriToLB(      this, CUI_RES( LB_HORITO      ) ),
     536             : 
     537           0 :     m_aHoriMirrorCB(  this, CUI_RES( CB_HORIMIRROR  ) ),
     538             : 
     539           0 :     m_aVertFT(        this, CUI_RES( FT_VERT        ) ),
     540           0 :     m_aVertLB(        this, CUI_RES( LB_VERT        ) ),
     541           0 :     m_aVertByFT(      this, CUI_RES( FT_VERTBY      ) ),
     542           0 :     m_aVertByMF(      this, CUI_RES( MF_VERTBY      ) ),
     543           0 :     m_aVertToFT(      this, CUI_RES( FT_VERTTO      ) ),
     544           0 :     m_aVertToLB(      this, CUI_RES( LB_VERTTO      ) ),
     545             : 
     546           0 :     m_aFollowCB(      this, CUI_RES( CB_FOLLOW      ) ),
     547           0 :     m_aExampleWN( this,   CUI_RES( WN_EXAMPLE ) ),
     548             : #ifdef _MSC_VER
     549             : #pragma warning (default : 4355)
     550             : #endif
     551             :     m_pVMap( 0 ),
     552             :     m_pHMap( 0 ),
     553             :     m_pSdrView( 0 ),
     554             :     m_nOldH(HoriOrientation::CENTER),
     555             :     m_nOldHRel(RelOrientation::FRAME),
     556             :     m_nOldV(VertOrientation::TOP),
     557             :     m_nOldVRel(RelOrientation::PRINT_AREA),
     558             :     m_fWidthHeightRatio(1.0),
     559             :     m_nHtmlMode(0),
     560             :     m_bHtmlMode(false),
     561             :     m_bAtHoriPosModified(false),
     562             :     m_bAtVertPosModified(false),
     563             :     m_bIsVerticalFrame(false),
     564             :     m_bPositioningDisabled(false),
     565             :     m_bIsMultiSelection(false),
     566           0 :     m_bIsInRightToLeft(false)
     567             : {
     568           0 :     FreeResource();
     569           0 :     FieldUnit eDlgUnit = GetModuleFieldUnit( rInAttrs );
     570           0 :     SetFieldUnit( m_aHoriByMF, eDlgUnit, sal_True );
     571           0 :     SetFieldUnit( m_aVertByMF, eDlgUnit, sal_True );
     572           0 :     SetFieldUnit( m_aWidthMF , eDlgUnit, sal_True );
     573           0 :     SetFieldUnit( m_aHeightMF, eDlgUnit, sal_True );
     574             : 
     575           0 :     SetExchangeSupport();
     576             : 
     577           0 :     Link aLk = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl);
     578           0 :     m_aWidthMF.    SetLoseFocusHdl( aLk );
     579           0 :     m_aHeightMF.   SetLoseFocusHdl( aLk );
     580           0 :     m_aHoriByMF.SetLoseFocusHdl( aLk );
     581           0 :     m_aVertByMF.SetLoseFocusHdl( aLk );
     582           0 :     m_aFollowCB.SetClickHdl( aLk );
     583             : 
     584           0 :     aLk = LINK(this, SvxSwPosSizeTabPage, ModifyHdl);
     585           0 :     m_aWidthMF.    SetModifyHdl( aLk );
     586           0 :     m_aHeightMF.   SetModifyHdl( aLk );
     587           0 :     m_aHoriByMF.SetModifyHdl( aLk );
     588           0 :     m_aVertByMF.SetModifyHdl( aLk );
     589             : 
     590           0 :     aLk = LINK(this, SvxSwPosSizeTabPage, AnchorTypeHdl);
     591           0 :     m_aToPageRB.SetClickHdl( aLk );
     592           0 :     m_aToParaRB.SetClickHdl( aLk );
     593           0 :     m_aToCharRB.SetClickHdl( aLk );
     594           0 :     m_aAsCharRB.SetClickHdl( aLk );
     595           0 :     m_aToFrameRB.SetClickHdl( aLk );
     596             : 
     597           0 :     m_aHoriLB.SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, PosHdl));
     598           0 :     m_aVertLB.  SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, PosHdl));
     599             : 
     600           0 :     m_aHoriToLB.SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, RelHdl));
     601           0 :     m_aVertToLB.SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, RelHdl));
     602             : 
     603           0 :     m_aHoriMirrorCB.SetClickHdl(LINK(this, SvxSwPosSizeTabPage, MirrorHdl));
     604           0 :     m_aPositionCB.SetClickHdl(LINK(this, SvxSwPosSizeTabPage, ProtectHdl));
     605           0 : }
     606             : 
     607           0 : SvxSwPosSizeTabPage::~SvxSwPosSizeTabPage()
     608             : {
     609           0 : }
     610             : 
     611           0 : SfxTabPage* SvxSwPosSizeTabPage::Create( Window* pParent, const SfxItemSet& rSet)
     612             : {
     613           0 :     return new SvxSwPosSizeTabPage(pParent, rSet);
     614             : }
     615             : 
     616           0 : sal_uInt16* SvxSwPosSizeTabPage::GetRanges()
     617             : {
     618             :     static sal_uInt16 pSwPosRanges[] =
     619             :     {
     620             :         SID_ATTR_TRANSFORM_POS_X,
     621             :         SID_ATTR_TRANSFORM_POS_Y,
     622             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     623             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     624             :         SID_ATTR_TRANSFORM_INTERN,
     625             :         SID_ATTR_TRANSFORM_INTERN,
     626             :         SID_ATTR_TRANSFORM_ANCHOR,
     627             :         SID_ATTR_TRANSFORM_VERT_ORIENT,
     628             :         SID_ATTR_TRANSFORM_WIDTH,
     629             :         SID_ATTR_TRANSFORM_SIZE_POINT,
     630             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     631             :         SID_ATTR_TRANSFORM_INTERN,
     632             :         SID_ATTR_TRANSFORM_AUTOWIDTH,
     633             :         SID_ATTR_TRANSFORM_VERT_ORIENT,
     634             :         SID_HTML_MODE,
     635             :         SID_HTML_MODE,
     636             :         SID_SW_FOLLOW_TEXT_FLOW,
     637             :         SID_SW_FOLLOW_TEXT_FLOW,
     638             :         SID_ATTR_TRANSFORM_HORI_POSITION,
     639             :         SID_ATTR_TRANSFORM_VERT_POSITION,
     640             :         0
     641             :     };
     642           0 :     return pSwPosRanges;
     643             : }
     644             : 
     645           0 : sal_Bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet& rSet)
     646             : {
     647           0 :     bool bAnchorChanged = false;
     648           0 :     short nAnchor = GetAnchorType(&bAnchorChanged);
     649           0 :     sal_Bool bModified = sal_False;
     650           0 :     if(bAnchorChanged)
     651             :     {
     652           0 :         rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
     653           0 :         bModified |= sal_True;
     654             :     }
     655           0 :     if ( m_aPositionCB.GetState() != m_aPositionCB.GetSavedValue() )
     656             :     {
     657           0 :         if( m_aPositionCB.GetState() == STATE_DONTKNOW )
     658           0 :             rSet.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS );
     659             :         else
     660             :             rSet.Put(
     661           0 :                 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ),
     662           0 :                 m_aPositionCB.GetState() == STATE_CHECK ? sal_True : sal_False ) );
     663           0 :         bModified |= sal_True;
     664             :     }
     665             : 
     666           0 :     if ( m_aSizeCB.GetState() != m_aSizeCB.GetSavedValue() )
     667             :     {
     668           0 :         if ( m_aSizeCB.GetState() == STATE_DONTKNOW )
     669           0 :             rSet.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE );
     670             :         else
     671             :             rSet.Put(
     672           0 :                 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ),
     673           0 :                 m_aSizeCB.GetState() == STATE_CHECK ? sal_True : sal_False ) );
     674           0 :         bModified |= sal_True;
     675             :     }
     676             : 
     677           0 :     const SfxItemSet& rOldSet = GetItemSet();
     678             : 
     679           0 :     if(!m_bPositioningDisabled)
     680             :     {
     681             :         //on multiple selections the positioning is set via SdrView
     682           0 :         if(m_bIsMultiSelection)
     683             :         {
     684           0 :             if( m_aHoriByMF.IsValueModified() || m_aVertByMF.IsValueModified() )
     685             :             {
     686             :                 long nHoriByPos =
     687           0 :                             static_cast<long>(m_aHoriByMF.Denormalize(m_aHoriByMF.GetValue(FUNIT_TWIP)));
     688             :                 long nVertByPos =
     689           0 :                             static_cast<long>(m_aVertByMF.Denormalize(m_aVertByMF.GetValue(FUNIT_TWIP)));
     690             : 
     691             :                 // old rectangle with CoreUnit
     692           0 :                 m_aRect = m_pSdrView->GetAllMarkedRect();
     693           0 :                 m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect );
     694             : 
     695           0 :                 nHoriByPos += m_aAnchorPos.X();
     696           0 :                 nVertByPos += m_aAnchorPos.Y();
     697             : 
     698           0 :                 rSet.Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_X ), nHoriByPos ) );
     699           0 :                 rSet.Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_Y ), nVertByPos ) );
     700             : 
     701           0 :                 bModified |= sal_True;
     702             :             }
     703             :         }
     704             :         else
     705             :         {
     706           0 :             if ( m_pHMap )
     707             :             {
     708             :                 const SfxInt16Item& rHoriOrient =
     709           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT));
     710             :                 const SfxInt16Item& rHoriRelation =
     711           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION));
     712             :                 const SfxInt32Item& rHoriPosition =
     713           0 :                         static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION)) ;
     714             : 
     715           0 :                 sal_uInt16 nMapPos = GetMapPos(m_pHMap, m_aHoriLB);
     716           0 :                 short nAlign = GetAlignment(m_pHMap, nMapPos, m_aHoriLB, m_aHoriToLB);
     717           0 :                 short nRel = GetRelation(m_pHMap, m_aHoriToLB);
     718             :                 const long nHoriByPos =
     719           0 :                             static_cast<long>(m_aHoriByMF.Denormalize(m_aHoriByMF.GetValue(FUNIT_TWIP)));
     720           0 :                 if (
     721           0 :                     nAlign != rHoriOrient.GetValue() ||
     722           0 :                     nRel != rHoriRelation.GetValue() ||
     723           0 :                     (m_aHoriByMF.IsEnabled() && nHoriByPos != rHoriPosition.GetValue())
     724             :                    )
     725             :                 {
     726           0 :                     rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, nAlign));
     727           0 :                     rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, nRel));
     728           0 :                     if(m_aHoriByMF.IsEnabled())
     729           0 :                         rSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, nHoriByPos));
     730           0 :                     bModified |= sal_True;
     731             :                 }
     732             :             }
     733           0 :             if(m_aHoriMirrorCB.IsEnabled() && m_aHoriMirrorCB.IsChecked() != m_aHoriMirrorCB.GetSavedValue())
     734           0 :                 bModified |= 0 != rSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, m_aHoriMirrorCB.IsChecked()));
     735             : 
     736           0 :             if ( m_pVMap )
     737             :             {
     738             :                 const SfxInt16Item& rVertOrient =
     739           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT));
     740             :                 const SfxInt16Item& rVertRelation =
     741           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION));
     742             :                 const SfxInt32Item& rVertPosition =
     743           0 :                         static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION));
     744             : 
     745           0 :                 sal_uInt16 nMapPos = GetMapPos(m_pVMap, m_aVertLB);
     746           0 :                 short nAlign = GetAlignment(m_pVMap, nMapPos, m_aVertLB, m_aVertToLB);
     747           0 :                 short nRel = GetRelation(m_pVMap, m_aVertToLB);
     748             :                 // #i34055# - convert vertical position for
     749             :                 // as-character anchored objects
     750             :                 long nVertByPos =
     751           0 :                         static_cast<long>(m_aVertByMF.Denormalize(m_aVertByMF.GetValue(FUNIT_TWIP)));
     752           0 :                 if ( GetAnchorType() == TextContentAnchorType_AS_CHARACTER )
     753             :                 {
     754           0 :                     nVertByPos *= -1;
     755             :                 }
     756           0 :                 if ( nAlign != rVertOrient.GetValue() ||
     757           0 :                      nRel != rVertRelation.GetValue() ||
     758           0 :                      ( m_aVertByMF.IsEnabled() &&
     759           0 :                        nVertByPos != rVertPosition.GetValue() ) )
     760             :                 {
     761           0 :                     rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, nAlign));
     762           0 :                     rSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, nRel));
     763           0 :                     if(m_aVertByMF.IsEnabled())
     764           0 :                         rSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, nVertByPos));
     765           0 :                     bModified |= sal_True;
     766             :                 }
     767             :             }
     768             : 
     769             :             // #i18732#
     770           0 :             if(m_aFollowCB.IsChecked() != m_aFollowCB.GetSavedValue())
     771             :             {
     772             :                 //Writer internal type - based on SfxBoolItem
     773           0 :                 const SfxPoolItem* pItem = GetItem( rOldSet, SID_SW_FOLLOW_TEXT_FLOW);
     774           0 :                 if(pItem)
     775             :                 {
     776           0 :                     SfxBoolItem* pFollow = static_cast<SfxBoolItem*>(pItem->Clone());
     777           0 :                     pFollow->SetValue(m_aFollowCB.IsChecked());
     778           0 :                     bModified |= 0 != rSet.Put(*pFollow);
     779           0 :                     delete pFollow;
     780             :                 }
     781             :             }
     782             :         }
     783             :     }
     784           0 :     if ( m_aWidthMF.IsValueModified() || m_aHeightMF.IsValueModified() )
     785             :     {
     786           0 :         sal_uInt32 nWidth = static_cast<sal_uInt32>(m_aWidthMF.Denormalize(m_aWidthMF.GetValue(FUNIT_TWIP)));
     787           0 :         sal_uInt32 nHeight = static_cast<sal_uInt32>(m_aHeightMF.Denormalize(m_aHeightMF.GetValue(FUNIT_TWIP)));
     788           0 :         rSet.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ),
     789           0 :                         (sal_uInt32) nWidth ) );
     790           0 :         rSet.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ),
     791           0 :                         (sal_uInt32) nHeight ) );
     792             :         //this item is required by SdrEditView::SetGeoAttrToMarked()
     793           0 :         rSet.Put( SfxAllEnumItem( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), RP_LT ) );
     794             : 
     795           0 :         bModified |= sal_True;
     796             :     }
     797             : 
     798           0 :     return bModified;
     799             : }
     800             : 
     801           0 : void SvxSwPosSizeTabPage::Reset( const SfxItemSet& rSet)
     802             : {
     803           0 :     const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_TRANSFORM_ANCHOR );
     804           0 :     bool bInvalidateAnchor = false;
     805           0 :     short nAnchorType = TextContentAnchorType_AT_PARAGRAPH;
     806           0 :     if(pItem)
     807             :     {
     808           0 :         nAnchorType = static_cast<const SfxInt16Item*>(pItem)->GetValue();
     809           0 :         switch(nAnchorType)
     810             :         {
     811           0 :             case  TextContentAnchorType_AT_PAGE:        m_aToPageRB.Check();  break;
     812           0 :             case  TextContentAnchorType_AT_PARAGRAPH:   m_aToParaRB.Check();  break;
     813           0 :             case  TextContentAnchorType_AT_CHARACTER:   m_aToCharRB.Check();  break;
     814           0 :             case  TextContentAnchorType_AS_CHARACTER:   m_aAsCharRB.Check();  break;
     815           0 :             case  TextContentAnchorType_AT_FRAME:       m_aToFrameRB.Check(); break;
     816           0 :             default : bInvalidateAnchor = true;
     817             :         }
     818           0 :         m_aToPageRB.SaveValue();
     819           0 :         m_aToParaRB.SaveValue();
     820           0 :         m_aToCharRB.SaveValue();
     821           0 :         m_aAsCharRB.SaveValue();
     822           0 :         m_aToFrameRB.SaveValue();
     823             :     }
     824           0 :     if(bInvalidateAnchor)
     825             :     {
     826           0 :         m_aToPageRB.Enable( sal_False );
     827           0 :         m_aToParaRB.Enable( sal_False );
     828           0 :         m_aToCharRB.Enable( sal_False );
     829           0 :         m_aAsCharRB.Enable( sal_False );
     830           0 :         m_aToFrameRB.Enable( sal_False );
     831             :     }
     832             : 
     833           0 :     pItem = GetItem( rSet, SID_ATTR_TRANSFORM_PROTECT_POS );
     834           0 :     if ( pItem )
     835             :     {
     836           0 :         sal_Bool bProtected = ( ( const SfxBoolItem* )pItem )->GetValue();
     837           0 :         m_aPositionCB.SetState( bProtected ? STATE_CHECK : STATE_NOCHECK );
     838           0 :         m_aPositionCB.EnableTriState( sal_False );
     839           0 :         m_aSizeCB.Enable( !bProtected );
     840             :     }
     841             :     else
     842             :     {
     843           0 :         m_aPositionCB.SetState( STATE_DONTKNOW );
     844             :     }
     845             : 
     846           0 :     m_aPositionCB.SaveValue();
     847             : 
     848           0 :     pItem = GetItem( rSet, SID_ATTR_TRANSFORM_PROTECT_SIZE );
     849             : 
     850           0 :     if ( pItem )
     851             :     {
     852           0 :         m_aSizeCB.SetState( ( (const SfxBoolItem*)pItem )->GetValue()
     853           0 :                               ? STATE_CHECK : STATE_NOCHECK );
     854           0 :         m_aSizeCB.EnableTriState( sal_False );
     855             :     }
     856             :     else
     857           0 :         m_aSizeCB.SetState( STATE_DONTKNOW );
     858           0 :     m_aSizeCB.SaveValue();
     859             : 
     860           0 :     pItem = GetItem( rSet, SID_HTML_MODE );
     861           0 :     if(pItem)
     862           0 :         m_nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
     863           0 :     m_bHtmlMode = 0 != (m_bHtmlMode & HTMLMODE_ON);
     864             : 
     865           0 :     pItem = GetItem( rSet, SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT );
     866           0 :     if(pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue())
     867             :     {
     868           0 :         String sHLabel = m_aHoriFT.GetText();
     869           0 :         m_aHoriFT.SetText(m_aVertFT.GetText());
     870           0 :         m_aVertFT.SetText(sHLabel);
     871           0 :         m_bIsVerticalFrame = true;
     872             :     }
     873           0 :     pItem = GetItem( rSet, SID_ATTR_TRANSFORM_IN_RTL_TEXT);
     874           0 :     if(pItem)
     875           0 :         m_bIsInRightToLeft = static_cast<const SfxBoolItem*>(pItem)->GetValue();
     876             : 
     877           0 :     pItem = GetItem( rSet, SID_SW_FOLLOW_TEXT_FLOW);
     878           0 :     if(pItem)
     879             :     {
     880             :         const bool bFollowTextFlow =
     881           0 :             static_cast<const SfxBoolItem*>(pItem)->GetValue();
     882           0 :         m_aFollowCB.Check( bFollowTextFlow );
     883             :     }
     884           0 :     m_aFollowCB.SaveValue();
     885             : 
     886           0 :     if(m_bHtmlMode)
     887             :     {
     888           0 :         m_aHoriMirrorCB.Show(sal_False);
     889           0 :         m_aKeepRatioCB.Enable(sal_False);
     890             :         // #i18732# - hide checkbox in HTML mode
     891           0 :         m_aFollowCB.Show(sal_False);
     892             :     }
     893             :     else
     894             :     {
     895             :         // #i18732# correct enable/disable of check box 'Mirror on..'
     896           0 :         m_aHoriMirrorCB.Enable(!m_aAsCharRB.IsChecked() && !m_bIsMultiSelection);
     897             : 
     898             :         // #i18732# - enable/disable check box 'Follow text flow'.
     899           0 :         m_aFollowCB.Enable( m_aToParaRB.IsChecked() ||
     900           0 :                                   m_aToCharRB.IsChecked() );
     901             :     }
     902             : 
     903           0 :     pItem = GetItem( rSet, SID_ATTR_TRANSFORM_WIDTH );
     904           0 :     sal_Int32 nWidth = Max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, (sal_uInt32)1 );
     905             : 
     906           0 :     m_aWidthMF.SetValue(m_aWidthMF.Normalize(nWidth), FUNIT_TWIP);
     907             : 
     908           0 :     pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HEIGHT );
     909           0 :     sal_Int32 nHeight = Max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, (sal_uInt32)1 );
     910           0 :     m_aHeightMF.SetValue(m_aHeightMF.Normalize(nHeight), FUNIT_TWIP);
     911           0 :     m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
     912             : 
     913           0 :     if(!m_bPositioningDisabled)
     914             :     {
     915           0 :         pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HORI_ORIENT);
     916           0 :         if(pItem)
     917             :         {
     918           0 :             short nHoriOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue();
     919           0 :             m_nOldH = nHoriOrientation;
     920             :         }
     921           0 :         pItem = GetItem( rSet, SID_ATTR_TRANSFORM_VERT_ORIENT);
     922           0 :         if(pItem)
     923             :         {
     924           0 :             short nVertOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue();
     925           0 :             m_nOldV = nVertOrientation;
     926             :         }
     927           0 :         pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HORI_RELATION);
     928           0 :         if(pItem)
     929             :         {
     930           0 :             m_nOldHRel = static_cast< const SfxInt16Item*>(pItem)->GetValue();
     931             :         }
     932             : 
     933           0 :         pItem = GetItem( rSet, SID_ATTR_TRANSFORM_VERT_RELATION);
     934           0 :         if(pItem)
     935             :         {
     936           0 :             m_nOldVRel = static_cast< const SfxInt16Item*>(pItem)->GetValue();
     937             :         }
     938           0 :         pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HORI_MIRROR);
     939           0 :         if(pItem)
     940           0 :             m_aHoriMirrorCB.Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
     941           0 :         m_aHoriMirrorCB.SaveValue();
     942             : 
     943           0 :         sal_Int32 nHoriPos = 0;
     944           0 :         sal_Int32 nVertPos = 0;
     945           0 :         pItem = GetItem( rSet, SID_ATTR_TRANSFORM_HORI_POSITION);
     946           0 :         if(pItem)
     947           0 :             nHoriPos = static_cast<const SfxInt32Item*>(pItem)->GetValue();
     948           0 :         pItem = GetItem( rSet, SID_ATTR_TRANSFORM_VERT_POSITION);
     949           0 :         if(pItem)
     950           0 :             nVertPos = static_cast<const SfxInt32Item*>(pItem)->GetValue();
     951             : 
     952           0 :         InitPos(nAnchorType, m_nOldH, m_nOldHRel, m_nOldV, m_nOldVRel, nHoriPos, nVertPos);
     953             : 
     954           0 :         m_aVertByMF.SaveValue();
     955           0 :         m_aHoriByMF.SaveValue();
     956             :         // #i18732#
     957           0 :         m_aFollowCB.SaveValue();
     958             : 
     959           0 :         RangeModifyHdl(&m_aWidthMF);  // initially set maximum values
     960             :     }
     961           0 : }
     962             : 
     963           0 : int  SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
     964             : {
     965           0 :     if( _pSet )
     966           0 :         FillItemSet( *_pSet );
     967           0 :     return( LEAVE_PAGE );
     968             : }
     969             : 
     970           0 : void SvxSwPosSizeTabPage::EnableAnchorTypes(sal_uInt16 nAnchorEnable)
     971             : {
     972           0 :     if((nAnchorEnable & SVX_OBJ_AT_FLY))
     973           0 :         m_aToFrameRB.Show();
     974           0 :     if(!(nAnchorEnable & SVX_OBJ_PAGE))
     975           0 :         m_aToPageRB.Enable(sal_False);
     976           0 : }
     977             : 
     978           0 : short SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged)
     979             : {
     980           0 :     short nRet = -1;
     981           0 :     RadioButton* pCheckedButton = 0;
     982           0 :     if(m_aToParaRB.IsEnabled())
     983             :     {
     984           0 :         if(m_aToPageRB.IsChecked())
     985             :         {
     986           0 :             nRet = TextContentAnchorType_AT_PAGE;
     987           0 :             pCheckedButton = &m_aToPageRB;
     988             :         }
     989           0 :         else if(m_aToParaRB.IsChecked())
     990             :         {
     991           0 :             nRet = TextContentAnchorType_AT_PARAGRAPH;
     992           0 :             pCheckedButton = &m_aToParaRB;
     993             :         }
     994           0 :         else if(m_aToCharRB.IsChecked())
     995             :         {
     996           0 :             nRet = TextContentAnchorType_AT_CHARACTER;
     997           0 :             pCheckedButton = &m_aToCharRB;
     998             :         }
     999           0 :         else if(m_aAsCharRB.IsChecked())
    1000             :         {
    1001           0 :             nRet = TextContentAnchorType_AS_CHARACTER;
    1002           0 :             pCheckedButton = &m_aAsCharRB;
    1003             :         }
    1004           0 :         else if(m_aToFrameRB.IsChecked())
    1005             :         {
    1006           0 :             nRet = TextContentAnchorType_AT_FRAME;
    1007           0 :             pCheckedButton = &m_aToFrameRB;
    1008             :         }
    1009             :     }
    1010           0 :     if(pbHasChanged)
    1011             :     {
    1012           0 :          if(pCheckedButton)
    1013           0 :              *pbHasChanged = pCheckedButton->IsChecked() != pCheckedButton->GetSavedValue();
    1014             :          else
    1015           0 :              *pbHasChanged = false;
    1016             :     }
    1017           0 :    return nRet;
    1018             : }
    1019             : 
    1020           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl)
    1021             : {
    1022           0 :     if(m_bPositioningDisabled)
    1023           0 :         return 0;
    1024           0 :     SvxSwFrameValidation        aVal;
    1025             : 
    1026           0 :     aVal.nAnchorType = GetAnchorType();
    1027           0 :     aVal.bAutoHeight = false;
    1028           0 :     aVal.bAutoWidth = false;
    1029           0 :     aVal.bMirror = m_aHoriMirrorCB.IsChecked();
    1030             :     // #i18732#
    1031           0 :     aVal.bFollowTextFlow = m_aFollowCB.IsChecked();
    1032             : 
    1033           0 :     if ( m_pHMap )
    1034             :     {
    1035             :         // horizontal alignment
    1036           0 :         sal_uInt16 nMapPos = GetMapPos(m_pHMap, m_aHoriToLB);
    1037           0 :         sal_uInt16 nAlign = GetAlignment(m_pHMap, nMapPos, m_aHoriLB, m_aHoriToLB);
    1038           0 :         sal_uInt16 nRel = GetRelation(m_pHMap, m_aHoriToLB);
    1039             : 
    1040           0 :         aVal.nHoriOrient = (short)nAlign;
    1041           0 :         aVal.nHRelOrient = (short)nRel;
    1042             :     }
    1043             :     else
    1044           0 :         aVal.nHoriOrient = HoriOrientation::NONE;
    1045             : 
    1046           0 :     if ( m_pVMap )
    1047             :     {
    1048             :         // vertical alignment
    1049           0 :         sal_uInt16 nMapPos = GetMapPos(m_pVMap, m_aVertLB);
    1050           0 :         sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, m_aVertLB, m_aVertToLB);
    1051           0 :         sal_uInt16 nRel = GetRelation(m_pVMap, m_aVertToLB);
    1052             : 
    1053           0 :         aVal.nVertOrient = (short)nAlign;
    1054           0 :         aVal.nVRelOrient = (short)nRel;
    1055             :     }
    1056             :     else
    1057           0 :         aVal.nVertOrient = VertOrientation::NONE;
    1058             : 
    1059             :     const long nAtHorzPosVal =
    1060           0 :                     static_cast<long>(m_aHoriByMF.Denormalize(m_aHoriByMF.GetValue(FUNIT_TWIP)));
    1061             :     const long nAtVertPosVal =
    1062           0 :                     static_cast<long>(m_aVertByMF.Denormalize(m_aVertByMF.GetValue(FUNIT_TWIP)));
    1063             : 
    1064           0 :     aVal.nHPos = nAtHorzPosVal;
    1065           0 :     aVal.nVPos = nAtVertPosVal;
    1066             : 
    1067           0 :     sal_Int32 nWidth = static_cast<sal_uInt32>(m_aWidthMF. Denormalize(m_aWidthMF.GetValue(FUNIT_TWIP)));
    1068           0 :     sal_Int32 nHeight = static_cast<sal_uInt32>(m_aHeightMF.Denormalize(m_aHeightMF.GetValue(FUNIT_TWIP)));
    1069           0 :     aVal.nWidth  = nWidth;
    1070           0 :     aVal.nHeight = nHeight;
    1071             : 
    1072           0 :     if(m_aValidateLink.IsSet())
    1073           0 :         m_aValidateLink.Call(&aVal);
    1074             : 
    1075           0 :     nWidth = aVal.nWidth;
    1076           0 :     nHeight = aVal.nHeight;
    1077             : 
    1078             :     // minimum width also for style
    1079           0 :     m_aHeightMF.SetMin(m_aHeightMF.Normalize(aVal.nMinHeight), FUNIT_TWIP);
    1080           0 :     m_aWidthMF. SetMin(m_aWidthMF.Normalize(aVal.nMinWidth), FUNIT_TWIP);
    1081             : 
    1082           0 :     sal_Int32 nMaxWidth(aVal.nMaxWidth);
    1083           0 :     sal_Int32 nMaxHeight(aVal.nMaxHeight);
    1084             : 
    1085           0 :     sal_Int64 nTmp = m_aHeightMF.Normalize(nMaxHeight);
    1086           0 :     m_aHeightMF.SetMax(nTmp, FUNIT_TWIP);
    1087             : 
    1088           0 :     nTmp = m_aWidthMF.Normalize(nMaxWidth);
    1089           0 :     m_aWidthMF.SetMax(nTmp, FUNIT_TWIP);
    1090             : 
    1091           0 :     m_aHoriByMF.SetMin(m_aHoriByMF.Normalize(aVal.nMinHPos), FUNIT_TWIP);
    1092           0 :     m_aHoriByMF.SetMax(m_aHoriByMF.Normalize(aVal.nMaxHPos), FUNIT_TWIP);
    1093           0 :     if ( aVal.nHPos != nAtHorzPosVal )
    1094           0 :         m_aHoriByMF.SetValue(m_aHoriByMF.Normalize(aVal.nHPos), FUNIT_TWIP);
    1095             : 
    1096           0 :     m_aVertByMF.SetMin(m_aVertByMF.Normalize(aVal.nMinVPos ), FUNIT_TWIP);
    1097           0 :     m_aVertByMF.SetMax(m_aVertByMF.Normalize(aVal.nMaxVPos), FUNIT_TWIP);
    1098           0 :     if ( aVal.nVPos != nAtVertPosVal )
    1099           0 :         m_aVertByMF.SetValue(m_aVertByMF.Normalize(aVal.nVPos), FUNIT_TWIP);
    1100             : 
    1101           0 :     return 0;
    1102             : }
    1103             : 
    1104           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl)
    1105             : {
    1106           0 :     m_aHoriMirrorCB.Enable(!m_aAsCharRB.IsChecked() && !m_bIsMultiSelection);
    1107             : 
    1108             :     // #i18732# - enable check box 'Follow text flow' for anchor
    1109             :     // type to-paragraph' and to-character
    1110           0 :     m_aFollowCB.Enable( m_aToParaRB.IsChecked() || m_aToCharRB.IsChecked() );
    1111             : 
    1112           0 :     short nId = GetAnchorType();
    1113             : 
    1114           0 :     InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX);
    1115           0 :     RangeModifyHdl(0);
    1116             : 
    1117           0 :     if(m_bHtmlMode)
    1118             :     {
    1119           0 :         PosHdl(&m_aHoriLB);
    1120           0 :         PosHdl(&m_aVertLB);
    1121             :     }
    1122           0 :     return 0;
    1123             : }
    1124             : 
    1125           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl)
    1126             : {
    1127           0 :     short nId = GetAnchorType();
    1128           0 :     InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX);
    1129             : 
    1130           0 :     return 0;
    1131             : }
    1132             : 
    1133           0 : IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, ListBox *, pLB )
    1134             : {
    1135           0 :     sal_Bool bHori = pLB == &m_aHoriToLB;
    1136             : 
    1137           0 :     UpdateExample();
    1138             : 
    1139           0 :     if (bHori)
    1140           0 :         m_bAtHoriPosModified = sal_True;
    1141             :     else
    1142           0 :         m_bAtVertPosModified = sal_True;
    1143             : 
    1144           0 :     if(m_bHtmlMode  && TextContentAnchorType_AT_CHARACTER == GetAnchorType()) // again special treatment
    1145             :     {
    1146           0 :         if(bHori)
    1147             :         {
    1148           0 :             sal_uInt16 nRel = GetRelation(m_pHMap, m_aHoriToLB);
    1149           0 :             if(RelOrientation::PRINT_AREA == nRel && 0 == m_aVertLB.GetSelectEntryPos())
    1150             :             {
    1151           0 :                 m_aVertLB.SelectEntryPos(1);
    1152             :             }
    1153           0 :             else if(RelOrientation::CHAR == nRel && 1 == m_aVertLB.GetSelectEntryPos())
    1154             :             {
    1155           0 :                 m_aVertLB.SelectEntryPos(0);
    1156             :             }
    1157             :         }
    1158             :     }
    1159           0 :     if (pLB)    // only if the hanlder has been called by a change of the controller
    1160           0 :         RangeModifyHdl(0);
    1161             : 
    1162           0 :     return 0;
    1163             : 
    1164             : }
    1165             : 
    1166           0 : IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox *, pLB )
    1167             : {
    1168           0 :     sal_Bool bHori = pLB == &m_aHoriLB;
    1169           0 :     ListBox *pRelLB = bHori ? &m_aHoriToLB : &m_aVertToLB;
    1170           0 :     FixedText *pRelFT = bHori ? &m_aHoriToFT : &m_aVertToFT;
    1171           0 :     FrmMap *pMap = bHori ? m_pHMap : m_pVMap;
    1172             : 
    1173             : 
    1174           0 :     sal_uInt16 nMapPos = GetMapPos(pMap, *pLB);
    1175           0 :     sal_uInt16 nAlign = GetAlignment(pMap, nMapPos, *pLB, *pRelLB);
    1176             : 
    1177           0 :     if (bHori)
    1178             :     {
    1179           0 :         sal_Bool bEnable = HoriOrientation::NONE == nAlign;
    1180           0 :         m_aHoriByMF.Enable( bEnable );
    1181           0 :         m_aHoriByFT.Enable( bEnable );
    1182             :     }
    1183             :     else
    1184             :     {
    1185           0 :         sal_Bool bEnable = VertOrientation::NONE == nAlign;
    1186           0 :         m_aVertByMF.Enable( bEnable );
    1187           0 :         m_aVertByFT.Enable( bEnable );
    1188             :     }
    1189             : 
    1190           0 :     if (pLB)    // only if the hanlder has been called by a change of the controller
    1191           0 :         RangeModifyHdl( 0 );
    1192             : 
    1193           0 :     short nRel = 0;
    1194           0 :     if (pLB->GetSelectEntryCount())
    1195             :     {
    1196             : 
    1197           0 :         if (pRelLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
    1198           0 :             nRel = ((RelationMap *)pRelLB->GetEntryData(pRelLB->GetSelectEntryPos()))->nRelation;
    1199             : 
    1200           0 :         FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT);
    1201             :     }
    1202             :     else
    1203           0 :         pRelLB->Clear();
    1204             : 
    1205           0 :     UpdateExample();
    1206             : 
    1207           0 :     if (bHori)
    1208           0 :         m_bAtHoriPosModified = sal_True;
    1209             :     else
    1210           0 :         m_bAtVertPosModified = sal_True;
    1211             : 
    1212             :     // special treatment for HTML-Mode with horz-vert-dependencies
    1213           0 :     if(m_bHtmlMode && TextContentAnchorType_AT_CHARACTER == GetAnchorType())
    1214             :     {
    1215           0 :         sal_Bool bSet = sal_False;
    1216           0 :         if(bHori)
    1217             :         {
    1218             :             // on the right only below is allowed - from the left only at the top
    1219             :             // from the left at the character -> below
    1220           0 :             if((HoriOrientation::LEFT == nAlign || HoriOrientation::RIGHT == nAlign) &&
    1221           0 :                     0 == m_aVertLB.GetSelectEntryPos())
    1222             :             {
    1223           0 :                 if(RelOrientation::FRAME == nRel)
    1224           0 :                     m_aVertLB.SelectEntryPos(1);
    1225             :                 else
    1226           0 :                     m_aVertLB.SelectEntryPos(0);
    1227           0 :                 bSet = sal_True;
    1228             :             }
    1229           0 :             else if(HoriOrientation::LEFT == nAlign && 1 == m_aVertLB.GetSelectEntryPos())
    1230             :             {
    1231           0 :                 m_aVertLB.SelectEntryPos(0);
    1232           0 :                 bSet = sal_True;
    1233             :             }
    1234           0 :             else if(HoriOrientation::NONE == nAlign && 1 == m_aVertLB.GetSelectEntryPos())
    1235             :             {
    1236           0 :                 m_aVertLB.SelectEntryPos(0);
    1237           0 :                 bSet = sal_True;
    1238             :             }
    1239           0 :             if(bSet)
    1240           0 :                 PosHdl(&m_aVertLB);
    1241             :         }
    1242             :         else
    1243             :         {
    1244           0 :             if(VertOrientation::TOP == nAlign)
    1245             :             {
    1246           0 :                 if(1 == m_aHoriLB.GetSelectEntryPos())
    1247             :                 {
    1248           0 :                     m_aHoriLB.SelectEntryPos(0);
    1249           0 :                     bSet = sal_True;
    1250             :                 }
    1251           0 :                 m_aHoriToLB.SelectEntryPos(1);
    1252             :             }
    1253           0 :             else if(VertOrientation::CHAR_BOTTOM == nAlign)
    1254             :             {
    1255           0 :                 if(2 == m_aHoriLB.GetSelectEntryPos())
    1256             :                 {
    1257           0 :                     m_aHoriLB.SelectEntryPos(0);
    1258           0 :                     bSet = sal_True;
    1259             :                 }
    1260           0 :                 m_aHoriToLB.SelectEntryPos(0) ;
    1261             :             }
    1262           0 :             if(bSet)
    1263           0 :                 PosHdl(&m_aHoriLB);
    1264             :         }
    1265             : 
    1266             :     }
    1267           0 :     return 0;
    1268             : }
    1269             : 
    1270           0 : IMPL_LINK( SvxSwPosSizeTabPage, ModifyHdl, Edit *, pEdit )
    1271             : {
    1272           0 :     sal_Int64 nWidth = m_aWidthMF.Denormalize(m_aWidthMF.GetValue(FUNIT_TWIP));
    1273           0 :     sal_Int64 nHeight = m_aHeightMF.Denormalize(m_aHeightMF.GetValue(FUNIT_TWIP));
    1274           0 :     if ( m_aKeepRatioCB.IsChecked() )
    1275             :     {
    1276           0 :         if ( pEdit == &m_aWidthMF )
    1277             :         {
    1278           0 :             nHeight = sal_Int64((double)nWidth / m_fWidthHeightRatio);
    1279           0 :             m_aHeightMF.SetValue(m_aHeightMF.Normalize(nHeight), FUNIT_TWIP);
    1280             :         }
    1281           0 :         else if(pEdit == &m_aHeightMF)
    1282             :         {
    1283           0 :             nWidth = sal_Int64((double)nHeight * m_fWidthHeightRatio);
    1284           0 :             m_aWidthMF.SetValue(m_aWidthMF.Normalize(nWidth), FUNIT_TWIP);
    1285             :         }
    1286             :     }
    1287           0 :     m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
    1288           0 :     UpdateExample();
    1289           0 :     return 0;
    1290             : }
    1291             : 
    1292           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl)
    1293             : {
    1294           0 :     m_aSizeCB.Enable(m_aPositionCB.IsEnabled() && !m_aPositionCB.IsChecked());
    1295           0 :     return 0;
    1296             : }
    1297             : 
    1298           0 : short SvxSwPosSizeTabPage::GetRelation(FrmMap *, ListBox &rRelationLB)
    1299             : {
    1300           0 :     short nRel = 0;
    1301           0 :     sal_uInt16 nPos = rRelationLB.GetSelectEntryPos();
    1302             : 
    1303           0 :     if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1304             :     {
    1305           0 :         RelationMap *pEntry = (RelationMap *)rRelationLB.GetEntryData(nPos);
    1306           0 :         nRel = pEntry->nRelation;
    1307             :     }
    1308             : 
    1309           0 :     return nRel;
    1310             : }
    1311             : 
    1312           0 : short SvxSwPosSizeTabPage::GetAlignment(FrmMap *pMap, sal_uInt16 nMapPos, ListBox &/*rAlignLB*/, ListBox &rRelationLB)
    1313             : {
    1314           0 :     short nAlign = 0;
    1315             : 
    1316             :     // #i22341# - special handling also for map <aVCharMap>,
    1317             :     // because it contains ambigous items for alignment
    1318           0 :     if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap ||
    1319             :             pMap == aVCharMap )
    1320             :     {
    1321           0 :         if (rRelationLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
    1322             :         {
    1323           0 :             sal_uLong  nRel = ((RelationMap *)rRelationLB.GetEntryData(rRelationLB.GetSelectEntryPos()))->nLBRelation;
    1324           0 :             std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1325           0 :             SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
    1326             : 
    1327           0 :             for (std::size_t i = 0; i < nMapCount; i++)
    1328             :             {
    1329           0 :                 if (pMap[i].eStrId == eStrId)
    1330             :                 {
    1331           0 :                     sal_uLong nLBRelations = pMap[i].nLBRelations;
    1332           0 :                     if (nLBRelations & nRel)
    1333             :                     {
    1334           0 :                         nAlign = pMap[i].nAlign;
    1335           0 :                         break;
    1336             :                     }
    1337             :                 }
    1338             :             }
    1339           0 :         }
    1340             :     }
    1341           0 :     else if (pMap)
    1342           0 :         nAlign = pMap[nMapPos].nAlign;
    1343             : 
    1344           0 :     return nAlign;
    1345             : }
    1346             : 
    1347           0 : sal_uInt16 SvxSwPosSizeTabPage::GetMapPos(FrmMap *pMap, ListBox &rAlignLB)
    1348             : {
    1349           0 :     sal_uInt16 nMapPos = 0;
    1350           0 :     sal_uInt16 nLBSelPos = rAlignLB.GetSelectEntryPos();
    1351             : 
    1352           0 :     if (nLBSelPos != LISTBOX_ENTRY_NOTFOUND)
    1353             :     {
    1354           0 :         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
    1355             :         {
    1356           0 :             std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1357           0 :             String sSelEntry(rAlignLB.GetSelectEntry());
    1358             : 
    1359           0 :             for (std::size_t i = 0; i < nMapCount; i++)
    1360             :             {
    1361           0 :                 SvxSwFramePosString::StringId eResId = pMap[i].eStrId;
    1362             : 
    1363           0 :                 String sEntry = m_aFramePosString.GetString(eResId);
    1364             : 
    1365           0 :                 if (sEntry == sSelEntry)
    1366             :                 {
    1367           0 :                     nMapPos = sal::static_int_cast< sal_uInt16 >(i);
    1368             :                     break;
    1369             :                 }
    1370           0 :             }
    1371             :         }
    1372             :         else
    1373           0 :             nMapPos = nLBSelPos;
    1374             :     }
    1375             : 
    1376           0 :     return nMapPos;
    1377             : }
    1378             : 
    1379           0 : void SvxSwPosSizeTabPage::InitPos(short nAnchor,
    1380             :                                 sal_uInt16 nH,
    1381             :                                 sal_uInt16 nHRel,
    1382             :                                 sal_uInt16 nV,
    1383             :                                 sal_uInt16 nVRel,
    1384             :                                 long   nX,
    1385             :                                 long   nY)
    1386             : {
    1387           0 :     sal_uInt16 nPos = m_aVertLB.GetSelectEntryPos();
    1388           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pVMap )
    1389             :     {
    1390           0 :         m_nOldV    = m_pVMap[nPos].nAlign;
    1391           0 :         nPos = m_aVertToLB.GetSelectEntryPos();
    1392           0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1393           0 :             m_nOldVRel = ((RelationMap *)m_aVertToLB.GetEntryData(nPos))->nRelation;
    1394             :     }
    1395             : 
    1396           0 :     nPos = m_aHoriLB.GetSelectEntryPos();
    1397           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pHMap )
    1398             :     {
    1399           0 :         m_nOldH    = m_pHMap[nPos].nAlign;
    1400             : 
    1401           0 :         nPos = m_aHoriToLB.GetSelectEntryPos();
    1402           0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1403           0 :             m_nOldHRel = ((RelationMap *)m_aHoriToLB.GetEntryData(nPos))->nRelation;
    1404             :     }
    1405             : 
    1406           0 :     sal_Bool bEnable = sal_True;
    1407           0 :     if( m_bIsMultiSelection )
    1408             :     {
    1409           0 :         m_pVMap = aVMultiSelectionMap;
    1410           0 :         m_pHMap = aHMultiSelectionMap;
    1411             :     }
    1412           0 :     else if( nAnchor == TextContentAnchorType_AT_PAGE )
    1413             :     {
    1414           0 :         m_pVMap = m_bHtmlMode ? aVPageHtmlMap : aVPageMap;
    1415           0 :         m_pHMap = m_bHtmlMode ? aHPageHtmlMap : aHPageMap;
    1416             :     }
    1417           0 :     else if ( nAnchor == TextContentAnchorType_AT_FRAME )
    1418             :     {
    1419             :         // #i18732# - own vertical alignment map for to frame
    1420             :         // anchored objects.
    1421           0 :         m_pVMap = m_bHtmlMode ? aVFlyHtmlMap : aVFrameMap;
    1422           0 :         m_pHMap = m_bHtmlMode ? aHFlyHtmlMap : aHFrameMap;
    1423             :     }
    1424           0 :     else if ( nAnchor == TextContentAnchorType_AT_PARAGRAPH )
    1425             :     {
    1426           0 :         if(m_bHtmlMode)
    1427             :         {
    1428           0 :             m_pVMap = aVParaHtmlMap;
    1429           0 :             m_pHMap = aHParaHtmlAbsMap;
    1430             :         }
    1431             :         else
    1432             :         {
    1433           0 :             m_pVMap = aVParaMap;
    1434           0 :             m_pHMap = aHParaMap;
    1435             :         }
    1436             :     }
    1437           0 :     else if ( nAnchor == TextContentAnchorType_AT_CHARACTER )
    1438             :     {
    1439           0 :         if(m_bHtmlMode)
    1440             :         {
    1441           0 :             m_pVMap = aVCharHtmlAbsMap;
    1442           0 :             m_pHMap = aHCharHtmlAbsMap;
    1443             :         }
    1444             :         else
    1445             :         {
    1446           0 :             m_pVMap = aVCharMap;
    1447           0 :             m_pHMap = aHCharMap;
    1448             :         }
    1449             :     }
    1450           0 :     else if ( nAnchor == TextContentAnchorType_AS_CHARACTER )
    1451             :     {
    1452           0 :         m_pVMap = m_bHtmlMode ? aVAsCharHtmlMap     : aVAsCharMap;
    1453           0 :         m_pHMap = 0;
    1454           0 :         bEnable = sal_False;
    1455             :     }
    1456           0 :     m_aHoriLB.Enable( bEnable );
    1457           0 :     m_aHoriFT.Enable( bEnable );
    1458             : 
    1459             :     // select current Pos
    1460             :     // horizontal
    1461           0 :     if ( nH == USHRT_MAX )
    1462             :     {
    1463           0 :         nH    = m_nOldH;
    1464           0 :         nHRel = m_nOldHRel;
    1465             :     }
    1466             :     // #i22341# - pass <nHRel> as 3rd parameter to method <FillPosLB>
    1467           0 :     sal_uInt16 nMapPos = FillPosLB(m_pHMap, nH, nHRel, m_aHoriLB);
    1468           0 :     FillRelLB(m_pHMap, nMapPos, nH, nHRel, m_aHoriToLB, m_aHoriToFT);
    1469             : 
    1470             :     // vertical
    1471           0 :     if ( nV == USHRT_MAX )
    1472             :     {
    1473           0 :         nV    = m_nOldV;
    1474           0 :         nVRel = m_nOldVRel;
    1475             :     }
    1476             :     // #i22341# - pass <nVRel> as 3rd parameter to method <FillPosLB>
    1477           0 :     nMapPos = FillPosLB(m_pVMap, nV, nVRel, m_aVertLB);
    1478           0 :     FillRelLB(m_pVMap, nMapPos, nV, nVRel, m_aVertToLB, m_aVertToFT);
    1479             : 
    1480             :     // Edits init
    1481             :     bEnable = nH == HoriOrientation::NONE &&
    1482           0 :             nAnchor != TextContentAnchorType_AS_CHARACTER;//#61359# why not in formats&& !bFormat;
    1483           0 :     if (!bEnable)
    1484             :     {
    1485           0 :         m_aHoriByMF.SetValue( 0, FUNIT_TWIP );
    1486           0 :         if (nX != LONG_MAX && m_bHtmlMode)
    1487           0 :             m_aHoriByMF.SetModifyFlag();
    1488             :     }
    1489           0 :     else if(m_bIsMultiSelection)
    1490             :     {
    1491           0 :          m_aHoriByMF.SetValue( m_aHoriByMF.Normalize(m_aRect.Left()), FUNIT_TWIP );
    1492             :     }
    1493             :     else
    1494             :     {
    1495           0 :         if (nX != LONG_MAX)
    1496           0 :             m_aHoriByMF.SetValue( m_aHoriByMF.Normalize(nX), FUNIT_TWIP );
    1497             :     }
    1498           0 :     m_aHoriByFT.Enable( bEnable );
    1499           0 :     m_aHoriByMF.Enable( bEnable );
    1500             : 
    1501           0 :     bEnable = nV == VertOrientation::NONE;
    1502           0 :     if ( !bEnable )
    1503             :     {
    1504           0 :         m_aVertByMF.SetValue( 0, FUNIT_TWIP );
    1505           0 :         if(nY != LONG_MAX && m_bHtmlMode)
    1506           0 :             m_aVertByMF.SetModifyFlag();
    1507             :     }
    1508           0 :     else if(m_bIsMultiSelection)
    1509             :     {
    1510           0 :          m_aVertByMF.SetValue( m_aVertByMF.Normalize(m_aRect.Top()), FUNIT_TWIP );
    1511             :     }
    1512             :     else
    1513             :     {
    1514           0 :         if ( nAnchor == TextContentAnchorType_AS_CHARACTER )
    1515             :         {
    1516           0 :             if ( nY == LONG_MAX )
    1517           0 :                 nY = 0;
    1518             :             else
    1519           0 :                 nY *= -1;
    1520             :         }
    1521           0 :         if ( nY != LONG_MAX )
    1522           0 :             m_aVertByMF.SetValue( m_aVertByMF.Normalize(nY), FUNIT_TWIP );
    1523             :     }
    1524           0 :     m_aVertByFT.Enable( bEnable );
    1525           0 :     m_aVertByMF.Enable( bEnable );
    1526           0 :     UpdateExample();
    1527           0 : }
    1528             : 
    1529           0 : void SvxSwPosSizeTabPage::UpdateExample()
    1530             : {
    1531           0 :     sal_uInt16 nPos = m_aHoriLB.GetSelectEntryPos();
    1532           0 :     if ( m_pHMap && nPos != LISTBOX_ENTRY_NOTFOUND )
    1533             :     {
    1534           0 :         sal_uInt16 nMapPos = GetMapPos(m_pHMap, m_aHoriLB);
    1535           0 :         short nAlign = GetAlignment(m_pHMap, nMapPos, m_aHoriLB, m_aHoriToLB);
    1536           0 :         short nRel = GetRelation(m_pHMap, m_aHoriToLB);
    1537             : 
    1538           0 :         m_aExampleWN.SetHAlign(nAlign);
    1539           0 :         m_aExampleWN.SetHoriRel(nRel);
    1540             :     }
    1541             : 
    1542           0 :     nPos = m_aVertLB.GetSelectEntryPos();
    1543           0 :     if ( m_pVMap && nPos != LISTBOX_ENTRY_NOTFOUND )
    1544             :     {
    1545           0 :         sal_uInt16 nMapPos = GetMapPos(m_pVMap, m_aVertLB);
    1546           0 :         sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, m_aVertLB, m_aVertToLB);
    1547           0 :         sal_uInt16 nRel = GetRelation(m_pVMap, m_aVertToLB);
    1548             : 
    1549           0 :         m_aExampleWN.SetVAlign(nAlign);
    1550           0 :         m_aExampleWN.SetVertRel(nRel);
    1551             :     }
    1552             : 
    1553             :     // Size
    1554           0 :     long nXPos = static_cast<long>(m_aHoriByMF.Denormalize(m_aHoriByMF.GetValue(FUNIT_TWIP)));
    1555           0 :     long nYPos = static_cast<long>(m_aVertByMF.Denormalize(m_aVertByMF.GetValue(FUNIT_TWIP)));
    1556           0 :     m_aExampleWN.SetRelPos(Point(nXPos, nYPos));
    1557             : 
    1558           0 :     m_aExampleWN.SetAnchor( GetAnchorType() );
    1559           0 :     m_aExampleWN.Invalidate();
    1560           0 : }
    1561             : 
    1562           0 : sal_uLong SvxSwPosSizeTabPage::FillRelLB(FrmMap *pMap, sal_uInt16 nMapPos, sal_uInt16 nAlign,
    1563             :         sal_uInt16 nRel, ListBox &rLB, FixedText &rFT)
    1564             : {
    1565           0 :     String sSelEntry;
    1566           0 :     sal_uLong  nLBRelations = 0;
    1567           0 :     std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1568             : 
    1569           0 :     rLB.Clear();
    1570             : 
    1571           0 :     if (nMapPos < nMapCount)
    1572             :     {
    1573           0 :         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
    1574             :         {
    1575           0 :             String sOldEntry(rLB.GetSelectEntry());
    1576           0 :             sal_uInt16 nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
    1577           0 :             SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
    1578             : 
    1579           0 :             for (std::size_t _nMapPos = 0; _nMapPos < nMapCount; _nMapPos++)
    1580             :             {
    1581           0 :                 if (pMap[_nMapPos].eStrId == eStrId)
    1582             :                 {
    1583           0 :                     nLBRelations = pMap[_nMapPos].nLBRelations;
    1584           0 :                     for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
    1585             :                     {
    1586           0 :                         if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation)
    1587             :                         {
    1588           0 :                             SvxSwFramePosString::StringId sStrId1 = aAsCharRelationMap[nRelPos].eStrId;
    1589             : 
    1590           0 :                             sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1591           0 :                             String sEntry = m_aFramePosString.GetString(sStrId1);
    1592           0 :                             sal_uInt16 nPos = rLB.InsertEntry(sEntry);
    1593           0 :                             rLB.SetEntryData(nPos, &aAsCharRelationMap[nRelPos]);
    1594           0 :                             if (pMap[_nMapPos].nAlign == nAlign)
    1595           0 :                                 sSelEntry = sEntry;
    1596           0 :                             break;
    1597             :                         }
    1598             :                     }
    1599             :                 }
    1600             :             }
    1601           0 :             if (sSelEntry.Len())
    1602           0 :                 rLB.SelectEntry(sSelEntry);
    1603             :             else
    1604             :             {
    1605           0 :                 rLB.SelectEntry(sOldEntry);
    1606             : 
    1607           0 :                 if (!rLB.GetSelectEntryCount())
    1608             :                 {
    1609           0 :                     for (sal_uInt16 i = 0; i < rLB.GetEntryCount(); i++)
    1610             :                     {
    1611           0 :                         RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(i);
    1612           0 :                         if (pEntry->nLBRelation == LB_REL_CHAR) // Default
    1613             :                         {
    1614           0 :                             rLB.SelectEntryPos(i);
    1615           0 :                             break;
    1616             :                         }
    1617             :                     }
    1618             :                 }
    1619           0 :             }
    1620             :         }
    1621             :         else
    1622             :         {
    1623           0 :             sal_uInt16 nRelCount = SAL_N_ELEMENTS(aRelationMap);
    1624             : 
    1625             :             // #i22341# - special handling for map <aVCharMap>,
    1626             :             // because its ambigous in its <eStrId>/<eMirrorStrId>.
    1627           0 :             if ( pMap == aVCharMap )
    1628             :             {
    1629             :                 nLBRelations = ::lcl_GetLBRelationsForStrID( pMap,
    1630           0 :                                              ( m_aHoriMirrorCB.IsChecked()
    1631           0 :                                                ? pMap[nMapPos].eMirrorStrId
    1632           0 :                                                : pMap[nMapPos].eStrId ),
    1633           0 :                                              m_aHoriMirrorCB.IsChecked() );
    1634             :             }
    1635             :             else
    1636             :             {
    1637           0 :                 nLBRelations = pMap[nMapPos].nLBRelations;
    1638             :             }
    1639             : 
    1640           0 :             for (sal_uLong nBit = 1; nBit < 0x80000000; nBit <<= 1)
    1641             :             {
    1642           0 :                 if (nLBRelations & nBit)
    1643             :                 {
    1644           0 :                     for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
    1645             :                     {
    1646           0 :                         if (aRelationMap[nRelPos].nLBRelation == nBit)
    1647             :                         {
    1648           0 :                             SvxSwFramePosString::StringId sStrId1 = m_aHoriMirrorCB.IsChecked() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId;
    1649           0 :                             sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1650           0 :                             String sEntry = m_aFramePosString.GetString(sStrId1);
    1651           0 :                             sal_uInt16 nPos = rLB.InsertEntry(sEntry);
    1652           0 :                             rLB.SetEntryData(nPos, &aRelationMap[nRelPos]);
    1653           0 :                             if (!sSelEntry.Len() && aRelationMap[nRelPos].nRelation == nRel)
    1654           0 :                                 sSelEntry = sEntry;
    1655             :                         }
    1656             :                     }
    1657             :                 }
    1658             :             }
    1659           0 :             if (sSelEntry.Len())
    1660           0 :                 rLB.SelectEntry(sSelEntry);
    1661             :             else
    1662             :             {
    1663             :                 // Probably anchor change. So look for a similar relation.
    1664           0 :                 switch (nRel)
    1665             :                 {
    1666           0 :                     case RelOrientation::FRAME:             nRel = RelOrientation::PAGE_FRAME;    break;
    1667           0 :                     case RelOrientation::PRINT_AREA:        nRel = RelOrientation::PAGE_PRINT_AREA;  break;
    1668           0 :                     case RelOrientation::PAGE_LEFT:       nRel = RelOrientation::FRAME_LEFT;    break;
    1669           0 :                     case RelOrientation::PAGE_RIGHT:      nRel = RelOrientation::FRAME_RIGHT;   break;
    1670           0 :                     case RelOrientation::FRAME_LEFT:      nRel = RelOrientation::PAGE_LEFT;     break;
    1671           0 :                     case RelOrientation::FRAME_RIGHT:     nRel = RelOrientation::PAGE_RIGHT;    break;
    1672           0 :                     case RelOrientation::PAGE_FRAME:      nRel = RelOrientation::FRAME;           break;
    1673           0 :                     case RelOrientation::PAGE_PRINT_AREA: nRel = RelOrientation::PRINT_AREA;         break;
    1674             : 
    1675             :                     default:
    1676           0 :                         if (rLB.GetEntryCount())
    1677             :                         {
    1678           0 :                             RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(rLB.GetEntryCount() - 1);
    1679           0 :                             nRel = pEntry->nRelation;
    1680             :                         }
    1681           0 :                         break;
    1682             :                 }
    1683             : 
    1684           0 :                 for (sal_uInt16 i = 0; i < rLB.GetEntryCount(); i++)
    1685             :                 {
    1686           0 :                     RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(i);
    1687           0 :                     if (pEntry->nRelation == nRel)
    1688             :                     {
    1689           0 :                         rLB.SelectEntryPos(i);
    1690           0 :                         break;
    1691             :                     }
    1692             :                 }
    1693             : 
    1694           0 :                 if (!rLB.GetSelectEntryCount())
    1695           0 :                     rLB.SelectEntryPos(0);
    1696             :             }
    1697             :         }
    1698             :     }
    1699             : 
    1700           0 :     rLB.Enable(rLB.GetEntryCount() != 0);
    1701           0 :     rFT.Enable(rLB.GetEntryCount() != 0);
    1702             : 
    1703           0 :     RelHdl(&rLB);
    1704             : 
    1705           0 :     return nLBRelations;
    1706             : }
    1707             : 
    1708           0 : sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap *_pMap,
    1709             :                                       sal_uInt16 _nAlign,
    1710             :                                       const sal_uInt16 _nRel,
    1711             :                                       ListBox &_rLB)
    1712             : {
    1713           0 :     String sSelEntry, sOldEntry;
    1714           0 :     sOldEntry = _rLB.GetSelectEntry();
    1715             : 
    1716           0 :     _rLB.Clear();
    1717             : 
    1718             :     // #i22341# - determine all possible listbox relations for
    1719             :     // given relation for map <aVCharMap>
    1720             :     const sal_uLong nLBRelations = (_pMap != aVCharMap)
    1721             :                                ? 0L
    1722           0 :                                : ::lcl_GetLBRelationsForRelations( _nRel );
    1723             : 
    1724             :     // fill listbox
    1725           0 :     std::size_t nCount = ::lcl_GetFrmMapCount(_pMap);
    1726           0 :     for (std::size_t i = 0; _pMap && i < nCount; ++i)
    1727             :     {
    1728             : //      #61359# why not from the left/from inside or from the top?
    1729             : //      if (!bFormat || (pMap[i].eStrId != SwFPos::FROMLEFT && pMap[i].eStrId != SwFPos::FROMTOP))
    1730             :         {
    1731           0 :             SvxSwFramePosString::StringId eStrId = m_aHoriMirrorCB.IsChecked() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId;
    1732           0 :             eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1733           0 :             String sEntry(m_aFramePosString.GetString(eStrId));
    1734           0 :             if (_rLB.GetEntryPos(sEntry) == LISTBOX_ENTRY_NOTFOUND)
    1735             :             {
    1736             :                 // don't insert duplicate entries at character wrapped borders
    1737           0 :                 _rLB.InsertEntry(sEntry);
    1738             :             }
    1739             :             // #i22341# - add condition to handle map <aVCharMap>
    1740             :             // that is ambigous in the alignment.
    1741           0 :             if ( _pMap[i].nAlign == _nAlign &&
    1742           0 :                  ( !(_pMap == aVCharMap) || _pMap[i].nLBRelations & nLBRelations ) )
    1743             :             {
    1744           0 :                 sSelEntry = sEntry;
    1745           0 :             }
    1746             :         }
    1747             :     }
    1748             : 
    1749           0 :     _rLB.SelectEntry(sSelEntry);
    1750           0 :     if (!_rLB.GetSelectEntryCount())
    1751           0 :         _rLB.SelectEntry(sOldEntry);
    1752             : 
    1753           0 :     if (!_rLB.GetSelectEntryCount())
    1754           0 :         _rLB.SelectEntryPos(0);
    1755             : 
    1756           0 :     PosHdl(&_rLB);
    1757             : 
    1758           0 :     return GetMapPos(_pMap, _rLB);
    1759             : }
    1760             : 
    1761           0 : void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView )
    1762             : {
    1763           0 :     m_pSdrView = pSdrView;
    1764           0 :     if(!m_pSdrView)
    1765             :     {
    1766             :         OSL_FAIL("No SdrView* set");
    1767           0 :         return;
    1768             :     }
    1769             : 
    1770             :     // setting of the rectangle and the working area
    1771           0 :     m_aRect = m_pSdrView->GetAllMarkedRect();
    1772           0 :     m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect );
    1773             : 
    1774             :     // get WorkArea
    1775           0 :     m_aWorkArea = m_pSdrView->GetWorkArea();
    1776             : 
    1777             :     // consider anchor position (for Writer)
    1778           0 :     const SdrMarkList& rMarkList = m_pSdrView->GetMarkedObjectList();
    1779           0 :     if( rMarkList.GetMarkCount() >= 1 )
    1780             :     {
    1781           0 :         const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
    1782           0 :         m_aAnchorPos = pObj->GetAnchorPos();
    1783             : 
    1784           0 :         if( m_aAnchorPos != Point(0,0) ) // -> Writer
    1785             :         {
    1786           0 :             for( sal_uInt16 i = 1; i < rMarkList.GetMarkCount(); i++ )
    1787             :             {
    1788           0 :                 pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
    1789           0 :                 if( m_aAnchorPos != pObj->GetAnchorPos() )
    1790             :                 {
    1791             :                     // different anchor positions -> disable positioning
    1792           0 :                     m_aPositionFL.Enable(sal_False);
    1793           0 :                     m_aHoriFT.Enable(sal_False);
    1794           0 :                     m_aHoriLB.Enable(sal_False);
    1795           0 :                     m_aHoriByFT.Enable(sal_False);
    1796           0 :                     m_aHoriByMF.Enable(sal_False);
    1797           0 :                     m_aHoriToFT.Enable(sal_False);
    1798           0 :                     m_aHoriToLB.Enable(sal_False);
    1799           0 :                     m_aHoriMirrorCB.Enable(sal_False);
    1800           0 :                     m_aVertFT.Enable(sal_False);
    1801           0 :                     m_aVertLB.Enable(sal_False);
    1802           0 :                     m_aVertByFT.Enable(sal_False);
    1803           0 :                     m_aVertByMF.Enable(sal_False);
    1804           0 :                     m_aVertToFT.Enable(sal_False);
    1805           0 :                     m_aVertToLB.Enable(sal_False);
    1806           0 :                     m_aFollowCB.Enable(sal_False);
    1807           0 :                     m_aHoriByMF.SetText(String());
    1808           0 :                     m_aVertByMF.SetText(String());
    1809             : 
    1810           0 :                     m_bPositioningDisabled = true;
    1811             :                     return;
    1812             :                 }
    1813             :             }
    1814             :         }
    1815           0 :         Point aPt = m_aAnchorPos * -1;
    1816           0 :         Point aPt2 = aPt;
    1817             : 
    1818           0 :         aPt += m_aWorkArea.TopLeft();
    1819           0 :         m_aWorkArea.SetPos( aPt );
    1820             : 
    1821           0 :         aPt2 += m_aRect.TopLeft();
    1822           0 :         m_aRect.SetPos( aPt2 );
    1823             :     }
    1824             : 
    1825             :     // this should happen via SID_ATTR_TRANSFORM_AUTOSIZE
    1826           0 :     if( rMarkList.GetMarkCount() != 1 )
    1827           0 :         m_bIsMultiSelection = true;
    1828             : #if OSL_DEBUG_LEVEL > 1
    1829             :     else
    1830             :     {
    1831             :         const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
    1832             :         SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
    1833             :         if( ( pObj->GetObjInventor() == SdrInventor ) &&
    1834             :             ( eKind==OBJ_TEXT || eKind==OBJ_TITLETEXT || eKind==OBJ_OUTLINETEXT) &&
    1835             :             ( (SdrTextObj*) pObj )->HasText() )
    1836             :         {
    1837             :             OSL_FAIL("AutoWidth/AutoHeight should be enabled");
    1838             :         }
    1839             :     }
    1840             : #endif
    1841           6 : }
    1842             : 
    1843             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10